Search in sources :

Example 6 with MetaverseDocument

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

the class FileSystemLocatorTest 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.setRepositoryId("test_repo");
    spyLocator.setMetaverseBuilder(metaverseBuilder);
    spyLocator.addDocumentListener(this);
    spyLocator.setRootFolder("src/test/resources/solution");
    TestFileSystemLocator.delay = 300;
    assertNotNull("Indexer type is null", spyLocator.getLocatorType());
    events = 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);
    assertTrue("Event count is wrong", events.size() > 0);
    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);
        }
    }
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) IDocumentEvent(org.pentaho.metaverse.api.IDocumentEvent) MetaverseDocument(org.pentaho.metaverse.api.MetaverseDocument) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) MetaverseBuilder(org.pentaho.metaverse.impl.MetaverseBuilder) Test(org.junit.Test)

Aggregations

MetaverseDocument (org.pentaho.metaverse.api.MetaverseDocument)6 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)4 Test (org.junit.Test)4 IDocumentEvent (org.pentaho.metaverse.api.IDocumentEvent)4 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)4 MetaverseBuilder (org.pentaho.metaverse.impl.MetaverseBuilder)4 Before (org.junit.Before)2 JobMeta (org.pentaho.di.job.JobMeta)2 TransMeta (org.pentaho.di.trans.TransMeta)2 Vertex (com.tinkerpop.blueprints.Vertex)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)1 MetaverseLocatorException (org.pentaho.metaverse.api.MetaverseLocatorException)1 GraphMLWriter (org.pentaho.metaverse.graph.GraphMLWriter)1 MetaverseNode (org.pentaho.metaverse.impl.MetaverseNode)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)1