use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testGetStepFieldOriginDescriptor.
@Test
public void testGetStepFieldOriginDescriptor() throws Exception {
when(mockStepFields.getFieldNames()).thenReturn(new String[] { "field1", "field2" });
analyzer.stepFields = mockStepFields;
IMetaverseNode rootNode = mock(IMetaverseNode.class);
when(rootNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE)).thenReturn("{}");
analyzer.rootNode = rootNode;
analyzer.setMetaverseObjectFactory(new MetaverseObjectFactory());
assertNotNull(analyzer.getStepFieldOriginDescriptor(mockDescriptor, "field1"));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateFieldNode.
@Test
public void testCreateFieldNode() throws Exception {
IComponentDescriptor fieldDescriptor = mock(IComponentDescriptor.class);
ValueMetaInterface fieldMeta = new ValueMeta("address");
MetaverseTransientNode node = new MetaverseTransientNode("hello");
doReturn(node).when(analyzer).createNodeFromDescriptor(fieldDescriptor);
IMetaverseNode fieldNode = analyzer.createFieldNode(fieldDescriptor, fieldMeta, "nextStep", true);
assertNotNull(fieldNode);
assertNotNull(fieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("nextStep", fieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
// make sure it got added to the graph
verify(builder).addNode(node);
}
use of org.pentaho.metaverse.api.IMetaverseNode 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.IMetaverseNode in project pentaho-metaverse by pentaho.
the class MetaverseUtilTest method testAddLineageGraph.
@Test
public void testAddLineageGraph() throws Exception {
IDocument document = mock(IDocument.class);
when(document.getName()).thenReturn("myDoc");
Object content = new Object();
when(document.getContent()).thenReturn(content);
IDocumentController documentController = mock(IDocumentController.class, withSettings().extraInterfaces(IRequiresMetaverseBuilder.class));
List<IDocumentAnalyzer> analyzers = new ArrayList<IDocumentAnalyzer>();
when(documentController.getDocumentAnalyzers(Mockito.anyString())).thenReturn(analyzers);
MetaverseUtil.documentController = documentController;
// Empty analyzer set
MetaverseUtil.addLineageGraph(document, null);
IDocumentAnalyzer<IMetaverseNode> documentAnalyzer = mock(IDocumentAnalyzer.class);
when(documentAnalyzer.analyze(Mockito.any(IComponentDescriptor.class), Mockito.any(IDocument.class))).thenReturn(mock(IMetaverseNode.class));
analyzers.add(documentAnalyzer);
Graph graph = new TinkerGraph();
MetaverseUtil.addLineageGraph(document, graph);
MetaverseUtil.addLineageGraph(document, null);
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class HTTPPostStepAnalyzer method createResourceNode.
@Override
public IMetaverseNode createResourceNode(IExternalResourceInfo resource) throws MetaverseException {
MetaverseComponentDescriptor componentDescriptor = new MetaverseComponentDescriptor(resource.getName(), getResourceInputNodeType(), descriptor.getNamespace(), descriptor.getContext());
IMetaverseNode node = createNodeFromDescriptor(componentDescriptor);
return node;
}
Aggregations