Search in sources :

Example 6 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.

the class DocumentControllerTest method setup.

@Before
public void setup() {
    docController = new DocumentController();
    IMetaverseBuilder builder = mock(IMetaverseBuilder.class);
    docController.setMetaverseBuilder(builder);
    IMetaverseObjectFactory objectFactory = mock(IMetaverseObjectFactory.class);
    docController.setMetaverseObjectFactory(objectFactory);
    initAnalyzers();
}
Also used : IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) Before(org.junit.Before)

Example 7 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.

the class LineageWriterTest method testOutputLineageGraph.

@Test
public void testOutputLineageGraph() throws Exception {
    Graph g = new TinkerGraph();
    IMetaverseBuilder builder = new MetaverseBuilder(g);
    holder.setMetaverseBuilder(builder);
    writer.setGraphOutputStream(System.out);
    IGraphWriter graphWriter = mock(IGraphWriter.class);
    writer.setGraphWriter(graphWriter);
    writer.outputLineageGraph(holder);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) IGraphWriter(org.pentaho.metaverse.api.IGraphWriter) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) Test(org.junit.Test)

Example 8 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.

the class DIRepositoryLocatorTest method testStopLocatorScan.

/**
 * Runs the spyLocator and checks the results
 *
 * @throws Exception When bad things happen
 */
@Test
public void testStopLocatorScan() throws Exception {
    TinkerGraph graph = new TinkerGraph();
    IMetaverseBuilder metaverseBuilder = new MetaverseBuilder(graph);
    spyLocator.setMetaverseBuilder(metaverseBuilder);
    spyLocator.addDocumentListener(this);
    spyLocator.setRepository(LocatorTestUtils.getFakeDiRepository());
    spyLocator.setUnifiedRepository(LocatorTestUtils.getMockIUnifiedRepository());
    LocatorTestUtils.delay = 300;
    assertNotNull("Indexer type is null", spyLocator.getLocatorType());
    events = Collections.synchronizedList(new ArrayList<IDocumentEvent>());
    System.out.println("call startScan");
    spyLocator.startScan();
    Thread.sleep(1000);
    System.out.println("call stopScan");
    spyLocator.stopScan();
    assertTrue("Event count is wrong", events.size() < 5);
    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 TransMeta);
        } else if (document.getExtension().equals("kjb")) {
            assertTrue(document.getContent() instanceof JobMeta);
        }
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) IDocumentEvent(org.pentaho.metaverse.api.IDocumentEvent) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) MetaverseDocument(org.pentaho.metaverse.api.MetaverseDocument) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) MetaverseBuilder(org.pentaho.metaverse.impl.MetaverseBuilder) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) Test(org.junit.Test)

Example 9 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder 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 10 with IMetaverseBuilder

use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.

the class MetaverseTestUtils method getDocumentController.

public static IDocumentController getDocumentController() {
    IDocumentController documentController = mock(IDocumentController.class);
    IMetaverseBuilder metaverseBuilder = mock(IMetaverseBuilder.class);
    when(metaverseBuilder.getMetaverseObjectFactory()).thenReturn(getMetaverseObjectFactory());
    when(documentController.getMetaverseObjectFactory()).thenReturn(getMetaverseObjectFactory());
    when(documentController.getMetaverseBuilder()).thenReturn(metaverseBuilder);
    return documentController;
}
Also used : IDocumentController(org.pentaho.metaverse.api.IDocumentController) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder)

Aggregations

IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)20 Test (org.junit.Test)12 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)10 Graph (com.tinkerpop.blueprints.Graph)7 MetaverseBuilder (org.pentaho.metaverse.impl.MetaverseBuilder)6 LineageHolder (org.pentaho.metaverse.api.model.LineageHolder)5 IDocumentEvent (org.pentaho.metaverse.api.IDocumentEvent)4 INamespace (org.pentaho.metaverse.api.INamespace)4 MetaverseDocument (org.pentaho.metaverse.api.MetaverseDocument)4 MetaverseException (org.pentaho.metaverse.api.MetaverseException)4 IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)4 JobMeta (org.pentaho.di.job.JobMeta)3 TransMeta (org.pentaho.di.trans.TransMeta)3 IDocument (org.pentaho.metaverse.api.IDocument)3 IDocumentController (org.pentaho.metaverse.api.IDocumentController)3 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)3 Namespace (org.pentaho.metaverse.api.Namespace)3 ExecutionProfile (org.pentaho.metaverse.impl.model.ExecutionProfile)3 Job (org.pentaho.di.job.Job)2 AnalysisContext (org.pentaho.metaverse.api.AnalysisContext)2