Search in sources :

Example 61 with IMetaverseNode

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"));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseObjectFactory(org.pentaho.metaverse.api.MetaverseObjectFactory) Test(org.junit.Test)

Example 62 with IMetaverseNode

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);
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 63 with IMetaverseNode

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());
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) MetaverseDocument(org.pentaho.metaverse.api.MetaverseDocument) MetaverseNode(org.pentaho.metaverse.impl.MetaverseNode) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Before(org.junit.Before)

Example 64 with IMetaverseNode

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);
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) IDocumentController(org.pentaho.metaverse.api.IDocumentController) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IDocumentAnalyzer(org.pentaho.metaverse.api.IDocumentAnalyzer) ArrayList(java.util.ArrayList) IRequiresMetaverseBuilder(org.pentaho.metaverse.api.IRequiresMetaverseBuilder) IDocument(org.pentaho.metaverse.api.IDocument) Test(org.junit.Test)

Example 65 with IMetaverseNode

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;
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Aggregations

IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)131 Test (org.junit.Test)77 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)30 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)23 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)16 ValueMeta (org.pentaho.di.core.row.ValueMeta)13 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)12 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)11 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)11 Vertex (com.tinkerpop.blueprints.Vertex)10 ArrayList (java.util.ArrayList)10 INamespace (org.pentaho.metaverse.api.INamespace)10 TransMeta (org.pentaho.di.trans.TransMeta)9 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)9 MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)9 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)8 Namespace (org.pentaho.metaverse.api.Namespace)8 StepField (org.pentaho.metaverse.api.StepField)8 HashMap (java.util.HashMap)7 Matchers.anyString (org.mockito.Matchers.anyString)7