EntityBundleLoader { public Bundle load(List<File> fileSet, BundleLoadingOperation loadingMode, String... entityTypes) { final Bundle bundle = new Bundle(); fileSet.forEach(f -> loadBundleFile(f, bundle, loadingMode, entityTypes)); return bundle; } @Inject  EntityBundleLoader(final DocumentTools documentTools, final BundleEntityLoaderRegistry entityLoaderRegistry, final JsonFileUtils jsonFileUtils); Bundle load(List<File> fileSet, BundleLoadingOperation loadingMode, String... entityTypes); Bundle load(File dependencyBundlePath, BundleLoadingOperation loadingMode, String... entityTypes); Bundle loadMetadata(File dependencyMetadataPath, BundleLoadingOperation loadingMode);  }
@Test void load() throws DocumentParseException { Document realDocument = DocumentTools.INSTANCE.getDocumentBuilder().newDocument(); Document mockDocument = mock(Document.class); when(mockDocument.getElementsByTagName(eq(ITEM))).thenReturn(new NodeList() { private List<Element> elements = Stream.of( TestUtils.createJdbcXml(realDocument), TestUtils.createCassandraXml(realDocument, true, true), TestUtils.createUnsupportedElement(realDocument) ).collect(toList()); @Override public Node item(int index) { return elements.get(index); } @Override public int getLength() { return elements.size(); } }); when(documentTools.parse(any(File.class))).thenReturn(mockDocument); EntityBundleLoader loader = new EntityBundleLoader(documentTools, registry, JsonFileUtils.INSTANCE); final Bundle bundle = loader.load(mock(File.class), BundleLoadingOperation.EXPORT); assertNotNull(bundle); assertFalse(bundle.getCassandraConnections().isEmpty()); assertFalse(bundle.getJdbcConnections().isEmpty()); assertEquals(1, bundle.getCassandraConnections().size()); assertEquals(1, bundle.getJdbcConnections().size()); }
@Test void tryLoadParseException() throws DocumentParseException { when(documentTools.parse(any(File.class))).thenThrow(DocumentParseException.class); assertThrows(BundleLoadException.class, () -> new EntityBundleLoader(documentTools, registry, JsonFileUtils.INSTANCE).load(mock(File.class), BundleLoadingOperation.EXPORT)); }