Search in sources :

Example 6 with MetaverseBuilder

use of org.pentaho.metaverse.impl.MetaverseBuilder 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

TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)6 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)6 MetaverseBuilder (org.pentaho.metaverse.impl.MetaverseBuilder)6 Test (org.junit.Test)4 IDocumentEvent (org.pentaho.metaverse.api.IDocumentEvent)4 MetaverseDocument (org.pentaho.metaverse.api.MetaverseDocument)4 Graph (com.tinkerpop.blueprints.Graph)2 JobMeta (org.pentaho.di.job.JobMeta)2 TransMeta (org.pentaho.di.trans.TransMeta)2 MetaverseException (org.pentaho.metaverse.api.MetaverseException)2 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 IDocument (org.pentaho.metaverse.api.IDocument)1 IDocumentAnalyzer (org.pentaho.metaverse.api.IDocumentAnalyzer)1 IDocumentController (org.pentaho.metaverse.api.IDocumentController)1 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)1 IMetaverseObjectFactory (org.pentaho.metaverse.api.IMetaverseObjectFactory)1 INamespace (org.pentaho.metaverse.api.INamespace)1 MetaverseLocatorException (org.pentaho.metaverse.api.MetaverseLocatorException)1 Namespace (org.pentaho.metaverse.api.Namespace)1