### Question:
KieModuleServiceImpl extends AbstractModuleService<KieModule> implements KieModuleFactory,
                   org.kie.workbench.common.services.shared.project.KieModuleService { @Override public KieModulePackages resolveModulePackages(Module activeModule) { final HashSet<PackageItem> packages = new HashSet<>(); packages.add(new PackageItem("", PackageItem.DEFAULT_PACKAGE_NAME)); for (final String packageName : packageServiceLoader.find(activeModule.getRootPath())) { final StringBuilder packageBuilder = new StringBuilder(); for (final String token : packageName.split("\\.")) { if (packageBuilder.length() != 0) { packageBuilder.append("."); } packageBuilder.append(token); packages.add(new PackageItem(packageBuilder.toString(), packageBuilder.toString())); } } return new KieModulePackages(packages, resolveDefaultWorkspacePackage(activeModule)); } KieModuleServiceImpl(); @Inject  KieModuleServiceImpl(final @Named("ioStrategy") IOService ioService,
                                final ModuleSaver moduleSaver,
                                final POMService pomService,
                                final RepositoryService repoService,
                                final Event<NewModuleEvent> newModuleEvent,
                                final Event<NewPackageEvent> newPackageEvent,
                                final Event<InvalidateDMOModuleCacheEvent> invalidateDMOCache,
                                final SessionInfo sessionInfo,
                                final CommentedOptionFactory commentedOptionFactory,
                                final ModuleFinder moduleFinder,
                                final PackageServiceLoader packageServiceLoader,
                                final KieResourceResolver resourceResolver,
                                final ModuleRepositoryResolver repositoryResolver); @Override KieModule newModule(final Path repositoryPath,
                               final POM pom); @Override KieModule newModule(final Path repositoryPath,
                               final POM pom,
                               final DeploymentMode mode); @Override KieModulePackages resolveModulePackages(Module activeModule); @Override Package resolvePackage(final Module activeModule,
                                  final String packageName); @Override Set<Package> resolvePackages(final Module activeModule,
                                        final Set<String> packageNames); @Override KieModule simpleModuleInstance(final org.uberfire.java.nio.file.Path nioModuleRootPath); @Override KieModule resolveModule(final Path resource); @Override KieModule resolveModule(Path resource, boolean loadPOM); @Override Module resolveParentModule(final Path resource); @Override Module resolveToParentModule(final Path resource); @Override Set<Package> resolvePackages(final Module project); @Override Set<Package> resolvePackages(final Package pkg); @Override Package resolveDefaultPackage(final Module project); @Override Package resolveDefaultWorkspacePackage(final Module project); @Override Path resolveDefaultPath(final Package pkg,
                                   final String resourceType); @Override Package resolveParentPackage(final Package pkg); @Override boolean isPom(final Path resource); @Override Package resolvePackage(final Path resource);  }### Answer:
@Test public void testNoPackages() { doReturn(new HashSet<>()).when(packageServiceLoader).find(rootPath); final KieModulePackages kieModulePackages = moduleService.resolveModulePackages(activeModule); assertEquals(1, kieModulePackages.getPackages().size()); assertEquals("", kieModulePackages.getPackages().iterator().next().getPackageName()); assertEquals("<default>", kieModulePackages.getPackages().iterator().next().getCaption()); }
@Test public void testPackages() { final HashSet<Object> packages = new HashSet<>(); packages.add("org.test"); doReturn(packages).when(packageServiceLoader).find(rootPath); final KieModulePackages kieModulePackages = moduleService.resolveModulePackages(activeModule); assertEquals(3, kieModulePackages.getPackages().size()); assertContains("", kieModulePackages); assertContains("org", kieModulePackages); assertContains("org.test", kieModulePackages); }