DataSetLoaderProvider implements LoaderProvider<Graph<Node, Edge>> { @Override public DataSetLoader<Graph<Node, Edge>> xmlLoader() { return (final File path) -> { try { final DefaultDirectedGraph<Node, Edge> graph = new DefaultDirectedGraph<>(new ClassBasedEdgeFactory<>(Edge.class)); final GraphMLReader<Node, Edge> importer = new GraphMLReader<>(graphElementFactory, graphElementFactory); importer.importGraph(graph, path); return graph; } catch (final ImportException e) { throw new IOException(e); } }; } DataSetLoaderProvider(final GraphElementFactory graphElementFactory); @Override DataSetLoader<Graph<Node, Edge>> xmlLoader(); @Override DataSetLoader<Graph<Node, Edge>> yamlLoader(); @Override DataSetLoader<Graph<Node, Edge>> jsonLoader(); @Override DataSetLoader<Graph<Node, Edge>> csvLoader(); @Override DataSetLoader<Graph<Node, Edge>> xlsLoader();  }
@Test public void testXmlLoaderLoadUsingProperResource() throws Exception { final DataSetLoader<Graph<Node, Edge>> loader = LOADER_PROVIDER.xmlLoader(); assertThat(loader, notNullValue()); final Graph<Node, Edge> graph = loader.load(getFile("test-data.xml")); assertThat(graph, notNullValue()); }
@Test(expected = NullPointerException.class) public void testXmlLoaderLoadUsingNullFileName() throws IOException { final DataSetLoader<Graph<Node, Edge>> loader = LOADER_PROVIDER.xmlLoader(); assertThat(loader, notNullValue()); loader.load(null); }
@Test(expected = IOException.class) public void testXmlLoaderLoadUsingWrongResource() throws Exception { final DataSetLoader<Graph<Node, Edge>> loader = LOADER_PROVIDER.xmlLoader(); assertThat(loader, notNullValue()); loader.load(getFile("test-data.csv")); }