@Test void testErrorOnDuplicatePolicies() throws IOException { File originFolder = new File(rootProjectDir.getRoot(), "original"); originFolder.mkdirs(); File destinationFolder = new File(rootProjectDir.getRoot(), "processed"); destinationFolder.mkdirs(); byte[] bundle2Contents = IOUtils.toByteArray(Thread.currentThread().getContextClassLoader().getResource(TEST_2_BUNDLE)); byte[] bundle3Contents = IOUtils.toByteArray(Thread.currentThread().getContextClassLoader().getResource(TEST_5_BUNDLE)); File file2 = new File(originFolder, TEST_2_BUNDLE); file2.createNewFile(); File file3 = new File(originFolder, TEST_5_BUNDLE); file3.createNewFile(); Files.write(file2.toPath(), bundle2Contents); Files.write(file3.toPath(), bundle3Contents); assertThrows(BundleLoadException.class, () -> processor.process(Stream.of(new File(originFolder, TEST_2_BUNDLE), new File(originFolder, TEST_3_BUNDLE)).collect(toCollection(LinkedList::new)), destinationFolder.toString())); }
public LinkedList<File> process(final List<File> bundles, String bundleFolderPath) { Bundle bundleObject = entityBundleLoader.load(bundles, BundleLoadingOperation.VALIDATE, ENCAPSULATED_ASSERTION_TYPE, EntityTypes.POLICY_TYPE, FOLDER_TYPE); LinkedList<File> processedBundles = new LinkedList<>(); for (File bundle : bundles) { Document document = parseBundleFile(bundle); Element bundleElement = document.getDocumentElement(); NodeList items = bundleElement.getElementsByTagName(ITEM); processEncasses(bundleObject, items); File processedBundle = writeProcessedBundle(bundle, bundleElement, bundleFolderPath); processedBundles.add(processedBundle); } return processedBundles; }
DependencyBundlesProcessor { public LinkedList<File> process(final List<File> bundles, String bundleFolderPath) { Bundle bundleObject = entityBundleLoader.load(bundles, BundleLoadingOperation.VALIDATE, ENCAPSULATED_ASSERTION_TYPE, EntityTypes.POLICY_TYPE, FOLDER_TYPE); LinkedList<File> processedBundles = new LinkedList<>(); for (File bundle : bundles) { Document document = parseBundleFile(bundle); Element bundleElement = document.getDocumentElement(); NodeList items = bundleElement.getElementsByTagName(ITEM); processEncasses(bundleObject, items); File processedBundle = writeProcessedBundle(bundle, bundleElement, bundleFolderPath); processedBundles.add(processedBundle); } return processedBundles; } }
DependencyBundlesProcessor { public LinkedList<File> process(final List<File> bundles, String bundleFolderPath) { Bundle bundleObject = entityBundleLoader.load(bundles, BundleLoadingOperation.VALIDATE, ENCAPSULATED_ASSERTION_TYPE, EntityTypes.POLICY_TYPE, FOLDER_TYPE); LinkedList<File> processedBundles = new LinkedList<>(); for (File bundle : bundles) { Document document = parseBundleFile(bundle); Element bundleElement = document.getDocumentElement(); NodeList items = bundleElement.getElementsByTagName(ITEM); processEncasses(bundleObject, items); File processedBundle = writeProcessedBundle(bundle, bundleElement, bundleFolderPath); processedBundles.add(processedBundle); } return processedBundles; } @Inject  DependencyBundlesProcessor(EntityBundleLoader entityBundleLoader, DocumentTools documentTools, DocumentFileUtils documentFileUtils); }
DependencyBundlesProcessor { public LinkedList<File> process(final List<File> bundles, String bundleFolderPath) { Bundle bundleObject = entityBundleLoader.load(bundles, BundleLoadingOperation.VALIDATE, ENCAPSULATED_ASSERTION_TYPE, EntityTypes.POLICY_TYPE, FOLDER_TYPE); LinkedList<File> processedBundles = new LinkedList<>(); for (File bundle : bundles) { Document document = parseBundleFile(bundle); Element bundleElement = document.getDocumentElement(); NodeList items = bundleElement.getElementsByTagName(ITEM); processEncasses(bundleObject, items); File processedBundle = writeProcessedBundle(bundle, bundleElement, bundleFolderPath); processedBundles.add(processedBundle); } return processedBundles; } @Inject  DependencyBundlesProcessor(EntityBundleLoader entityBundleLoader, DocumentTools documentTools, DocumentFileUtils documentFileUtils); LinkedList<File> process(final List<File> bundles, String bundleFolderPath); }
DependencyBundlesProcessor { public LinkedList<File> process(final List<File> bundles, String bundleFolderPath) { Bundle bundleObject = entityBundleLoader.load(bundles, BundleLoadingOperation.VALIDATE, ENCAPSULATED_ASSERTION_TYPE, EntityTypes.POLICY_TYPE, FOLDER_TYPE); LinkedList<File> processedBundles = new LinkedList<>(); for (File bundle : bundles) { Document document = parseBundleFile(bundle); Element bundleElement = document.getDocumentElement(); NodeList items = bundleElement.getElementsByTagName(ITEM); processEncasses(bundleObject, items); File processedBundle = writeProcessedBundle(bundle, bundleElement, bundleFolderPath); processedBundles.add(processedBundle); } return processedBundles; } @Inject  DependencyBundlesProcessor(EntityBundleLoader entityBundleLoader, DocumentTools documentTools, DocumentFileUtils documentFileUtils); LinkedList<File> process(final List<File> bundles, String bundleFolderPath);  }