use of org.pentaho.metaverse.api.MetaverseDocument 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);
}
}
}
use of org.pentaho.metaverse.api.MetaverseDocument in project pentaho-metaverse by pentaho.
the class LocatorRunnerTest method setUp.
@Before
public void setUp() throws Exception {
when(baseLocator.getMetaverseBuilder()).thenReturn(metaverseBuilder);
when(metaverseBuilder.getMetaverseObjectFactory()).thenReturn(metaverseObjectFactory);
when(metaverseObjectFactory.createDocumentObject()).thenReturn(new MetaverseDocument());
}
use of org.pentaho.metaverse.api.MetaverseDocument in project pentaho-metaverse by pentaho.
the class RepositoryLocatorTest method setUp.
@Before
public void setUp() throws Exception {
RepositoryLocator loc = new RepositoryLocator() {
@Override
protected IUnifiedRepository getUnifiedRepository(IPentahoSession session) throws Exception {
return null;
}
@Override
protected Object getContents(RepositoryFile locatedItem) throws Exception {
return null;
}
/**
* Returns the locator node for this locator. The locator node is the node in the metaverse
* that represents this locator. It is used to create a link from this locator to the documents
* that are found by/within it.
*
* @return The locator node in the metaverse
*/
@Override
public IMetaverseNode getLocatorNode() {
return new MetaverseNode(mock(Vertex.class));
}
@Override
public URI getRootUri() {
return null;
}
};
loc.setMetaverseBuilder(metaverseBuilder);
baseLocator = spy(loc);
when(baseLocator.getMetaverseBuilder()).thenReturn(metaverseBuilder);
when(metaverseBuilder.getMetaverseObjectFactory()).thenReturn(metaverseObjectFactory);
when(metaverseObjectFactory.createDocumentObject()).thenReturn(new MetaverseDocument());
}
use of org.pentaho.metaverse.api.MetaverseDocument 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"));
}
use of org.pentaho.metaverse.api.MetaverseDocument in project pentaho-metaverse by pentaho.
the class DIRepositoryLocatorTest 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.addDocumentListener(this);
spyLocator.setRepository(LocatorTestUtils.getFakeDiRepository());
LocatorTestUtils.delay = 0;
spyLocator.setRepositoryId("testrepo");
assertEquals("Repo id is wrong", "testrepo", spyLocator.getRepositoryId());
assertNotNull("Indexer type is null", spyLocator.getLocatorType());
events = new ArrayList<IDocumentEvent>();
spyLocator.startScan();
spyLocator.futureTask.get();
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 TransMeta);
} else if (document.getExtension().equals("kjb")) {
assertTrue(document.getContent() instanceof JobMeta);
}
}
spyLocator.removeDocumentListener(this);
events = new ArrayList<IDocumentEvent>();
spyLocator.startScan();
spyLocator.futureTask.get();
assertEquals("Event count is wrong", 0, events.size());
}
Aggregations