@Test public void ifWhiteListIsEmptyWhiteListEverything() throws Exception { final PackageNameWhiteListService packageNameWhiteListService = makeService(""); WhiteList filterPackageNames = packageNameWhiteListService.filterPackageNames(mock(KieModule.class), new ArrayList<String> () {{ add("a"); add("b"); add("c"); }}); assertEquals(3, filterPackageNames.size()); assertTrue(filterPackageNames.contains("a")); assertTrue(filterPackageNames.contains("b")); assertTrue(filterPackageNames.contains("c")); }
@Override public WhiteList filterPackageNames(final Module module, final Collection<String> packageNames) { if (packageNames == null) { return new WhiteList(); } else if (module instanceof KieModule) { final WhiteList whiteList = load(((KieModule) module).getPackageNamesWhiteListPath()); if (whiteList.isEmpty()) { return new WhiteList(packageNames); } else { for (Package aPackage : moduleService.resolvePackages(module)) { whiteList.add(aPackage.getPackageName()); } return new PackageNameWhiteListFilter(packageNames, whiteList).getFilteredPackageNames(); } } else { return new WhiteList(packageNames); } }
PackageNameWhiteListServiceImpl implements PackageNameWhiteListService { @Override public WhiteList filterPackageNames(final Module module, final Collection<String> packageNames) { if (packageNames == null) { return new WhiteList(); } else if (module instanceof KieModule) { final WhiteList whiteList = load(((KieModule) module).getPackageNamesWhiteListPath()); if (whiteList.isEmpty()) { return new WhiteList(packageNames); } else { for (Package aPackage : moduleService.resolvePackages(module)) { whiteList.add(aPackage.getPackageName()); } return new PackageNameWhiteListFilter(packageNames, whiteList).getFilteredPackageNames(); } } else { return new WhiteList(packageNames); } } }
PackageNameWhiteListServiceImpl implements PackageNameWhiteListService { @Override public WhiteList filterPackageNames(final Module module, final Collection<String> packageNames) { if (packageNames == null) { return new WhiteList(); } else if (module instanceof KieModule) { final WhiteList whiteList = load(((KieModule) module).getPackageNamesWhiteListPath()); if (whiteList.isEmpty()) { return new WhiteList(packageNames); } else { for (Package aPackage : moduleService.resolvePackages(module)) { whiteList.add(aPackage.getPackageName()); } return new PackageNameWhiteListFilter(packageNames, whiteList).getFilteredPackageNames(); } } else { return new WhiteList(packageNames); } } PackageNameWhiteListServiceImpl(); @Inject  PackageNameWhiteListServiceImpl(final @Named("ioStrategy") IOService ioService,
                                           final KieModuleService moduleService,
                                           final PackageNameWhiteListLoader loader,
                                           final PackageNameWhiteListSaver saver); }
PackageNameWhiteListServiceImpl implements PackageNameWhiteListService { @Override public WhiteList filterPackageNames(final Module module, final Collection<String> packageNames) { if (packageNames == null) { return new WhiteList(); } else if (module instanceof KieModule) { final WhiteList whiteList = load(((KieModule) module).getPackageNamesWhiteListPath()); if (whiteList.isEmpty()) { return new WhiteList(packageNames); } else { for (Package aPackage : moduleService.resolvePackages(module)) { whiteList.add(aPackage.getPackageName()); } return new PackageNameWhiteListFilter(packageNames, whiteList).getFilteredPackageNames(); } } else { return new WhiteList(packageNames); } } PackageNameWhiteListServiceImpl(); @Inject  PackageNameWhiteListServiceImpl(final @Named("ioStrategy") IOService ioService,
                                           final KieModuleService moduleService,
                                           final PackageNameWhiteListLoader loader,
                                           final PackageNameWhiteListSaver saver); void createModuleWhiteList(final Path packageNamesWhiteListPath,
                                                            final String initialContent); @Override WhiteList filterPackageNames(final Module module,
                                        final Collection<String> packageNames); @Override WhiteList load(final Path packageNamesWhiteListPath); @Override Path save(final Path path,
                     final WhiteList content,
                     final Metadata metadata,
                     final String comment); }
PackageNameWhiteListServiceImpl implements PackageNameWhiteListService { @Override public WhiteList filterPackageNames(final Module module, final Collection<String> packageNames) { if (packageNames == null) { return new WhiteList(); } else if (module instanceof KieModule) { final WhiteList whiteList = load(((KieModule) module).getPackageNamesWhiteListPath()); if (whiteList.isEmpty()) { return new WhiteList(packageNames); } else { for (Package aPackage : moduleService.resolvePackages(module)) { whiteList.add(aPackage.getPackageName()); } return new PackageNameWhiteListFilter(packageNames, whiteList).getFilteredPackageNames(); } } else { return new WhiteList(packageNames); } } PackageNameWhiteListServiceImpl(); @Inject  PackageNameWhiteListServiceImpl(final @Named("ioStrategy") IOService ioService,
                                           final KieModuleService moduleService,
                                           final PackageNameWhiteListLoader loader,
                                           final PackageNameWhiteListSaver saver); void createModuleWhiteList(final Path packageNamesWhiteListPath,
                                                            final String initialContent); @Override WhiteList filterPackageNames(final Module module,
                                        final Collection<String> packageNames); @Override WhiteList load(final Path packageNamesWhiteListPath); @Override Path save(final Path path,
                     final WhiteList content,
                     final Metadata metadata,
                     final String comment);  }