Search in sources :

Example 1 with GraphMLWriter

use of org.pentaho.metaverse.graph.GraphMLWriter in project pentaho-metaverse by pentaho.

the class FileSystemLineageWriterTest method testGetSetGraphOutputStream.

@Test
public void testGetSetGraphOutputStream() {
    assertNull(writer.getGraphOutputStream(null));
    IGraphWriter graphWriter = new GraphMLWriter();
    writer.setGraphWriter(graphWriter);
    assertNotNull(writer.getGraphOutputStream(holder));
    graphWriter = new GraphSONWriter();
    writer.setGraphWriter(graphWriter);
    assertNotNull(writer.getGraphOutputStream(holder));
    graphWriter = new GraphCsvWriter();
    writer.setGraphWriter(graphWriter);
    assertNotNull(writer.getGraphOutputStream(holder));
}
Also used : GraphSONWriter(org.pentaho.metaverse.graph.GraphSONWriter) GraphCsvWriter(org.pentaho.metaverse.graph.GraphCsvWriter) IGraphWriter(org.pentaho.metaverse.api.IGraphWriter) GraphMLWriter(org.pentaho.metaverse.graph.GraphMLWriter) Test(org.junit.Test)

Example 2 with GraphMLWriter

use of org.pentaho.metaverse.graph.GraphMLWriter in project pentaho-metaverse by pentaho.

the class FileSystemLocatorTest method testStartLocator.

/**
 * Runs the spyLocator and checks the results
 *
 * @throws Exception When bad things happen
 */
@Test
public void testStartLocator() throws Exception {
    TinkerGraph graph = new TinkerGraph();
    IMetaverseBuilder metaverseBuilder = new MetaverseBuilder(graph);
    spyLocator.setMetaverseBuilder(metaverseBuilder);
    spyLocator.setRepositoryId("testrepo");
    spyLocator.addDocumentListener(this);
    spyLocator.setRootFolder("src/test/resources/solution");
    assertEquals("Root folder is wrong", "src/test/resources/solution", spyLocator.getRootFolder());
    TestFileSystemLocator.delay = 0;
    spyLocator.setRootFolder("bogus");
    events = new ArrayList<IDocumentEvent>();
    try {
        spyLocator.startScan();
        MetaverseCompletionService.getInstance().waitTillEmpty();
        fail();
    } catch (MetaverseLocatorException e) {
        assertEquals("Event count is wrong", 0, events.size());
    }
    spyLocator.setRootFolder("src/test/resources/solution/folder 2/parse.ktr");
    events = new ArrayList<IDocumentEvent>();
    try {
        spyLocator.startScan();
        MetaverseCompletionService.getInstance().waitTillEmpty();
        fail();
    } catch (MetaverseLocatorException e) {
        assertEquals("Event count is wrong", 0, events.size());
    }
    spyLocator.setRootFolder("src/test/resources/solution");
    assertEquals("Repo id is wrong", "testrepo", spyLocator.getRepositoryId());
    assertNotNull("Indexer type is null", spyLocator.getLocatorType());
    events = new ArrayList<IDocumentEvent>();
    spyLocator.startScan();
    MetaverseCompletionService.getInstance().waitTillEmpty();
    assertEquals("Event count is wrong", 7, events.size());
    for (IDocumentEvent event : events) {
        System.out.println(event.getDocument().getStringID());
        assertNotNull(event.getDocument());
        MetaverseDocument document = (MetaverseDocument) event.getDocument();
        if (document.getExtension().equals("ktr")) {
            assertTrue(document.getContent() instanceof String);
        } else if (document.getExtension().equals("kjb")) {
            assertTrue(document.getContent() instanceof String);
        }
    }
    spyLocator.removeDocumentListener(this);
    events = new ArrayList<IDocumentEvent>();
    spyLocator.startScan();
    MetaverseCompletionService.getInstance().waitTillEmpty();
    assertEquals("Event count is wrong", 0, events.size());
    assertNotNull("Graph is null", graph);
    GraphMLWriter writer = new GraphMLWriter();
    writer.outputGraph(graph, new FileOutputStream(OUTPUT_FOLDER + "FileSystemLocatorTest.graphml"));
}
Also used : MetaverseLocatorException(org.pentaho.metaverse.api.MetaverseLocatorException) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) IDocumentEvent(org.pentaho.metaverse.api.IDocumentEvent) FileOutputStream(java.io.FileOutputStream) MetaverseDocument(org.pentaho.metaverse.api.MetaverseDocument) GraphMLWriter(org.pentaho.metaverse.graph.GraphMLWriter) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) MetaverseBuilder(org.pentaho.metaverse.impl.MetaverseBuilder) Test(org.junit.Test)

Example 3 with GraphMLWriter

use of org.pentaho.metaverse.graph.GraphMLWriter in project pentaho-metaverse by pentaho.

the class VfsLineageWriterTest method testSetGraphOutputStream.

@Test
public void testSetGraphOutputStream() throws IOException {
    try (OutputStream graphOutputStream = writer.getGraphOutputStream(null)) {
        assertNull(graphOutputStream);
    }
    IGraphWriter graphWriter = new GraphMLWriter();
    writer.setGraphWriter(graphWriter);
    try (OutputStream graphOutputStream = writer.getGraphOutputStream(holder)) {
        assertNotNull(graphOutputStream);
    }
    graphWriter = new GraphSONWriter();
    writer.setGraphWriter(graphWriter);
    try (OutputStream graphOutputStream = writer.getGraphOutputStream(holder)) {
        assertNotNull(graphOutputStream);
    }
    graphWriter = new GraphCsvWriter();
    writer.setGraphWriter(graphWriter);
    try (OutputStream graphOutputStream = writer.getGraphOutputStream(holder)) {
        assertNotNull(graphOutputStream);
    }
}
Also used : OutputStream(java.io.OutputStream) GraphSONWriter(org.pentaho.metaverse.graph.GraphSONWriter) GraphCsvWriter(org.pentaho.metaverse.graph.GraphCsvWriter) IGraphWriter(org.pentaho.metaverse.api.IGraphWriter) GraphMLWriter(org.pentaho.metaverse.graph.GraphMLWriter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 GraphMLWriter (org.pentaho.metaverse.graph.GraphMLWriter)3 IGraphWriter (org.pentaho.metaverse.api.IGraphWriter)2 GraphCsvWriter (org.pentaho.metaverse.graph.GraphCsvWriter)2 GraphSONWriter (org.pentaho.metaverse.graph.GraphSONWriter)2 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 IDocumentEvent (org.pentaho.metaverse.api.IDocumentEvent)1 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)1 MetaverseDocument (org.pentaho.metaverse.api.MetaverseDocument)1 MetaverseLocatorException (org.pentaho.metaverse.api.MetaverseLocatorException)1 MetaverseBuilder (org.pentaho.metaverse.impl.MetaverseBuilder)1