Search in sources :

Example 11 with MetaverseTransientNode

use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.

the class MongoDbInputStepAnalyzerTest method testCustomAnalyze.

@Test
public void testCustomAnalyze() throws Exception {
    when(meta.getJsonQuery()).thenReturn("{test:test}");
    when(meta.getCollection()).thenReturn("myCollection");
    when(meta.getQueryIsPipeline()).thenReturn(true);
    IMetaverseNode node = new MetaverseTransientNode("new node");
    analyzer.customAnalyze(meta, node);
    assertNotNull(node);
    assertEquals("{test:test}", node.getProperty(DictionaryConst.PROPERTY_QUERY));
    assertEquals("myCollection", node.getProperty(MongoDbInputStepAnalyzer.COLLECTION));
    assertTrue((Boolean) node.getProperty(MongoDbInputStepAnalyzer.AGG_PIPELINE));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) Test(org.junit.Test)

Example 12 with MetaverseTransientNode

use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.

the class MetaverseBuilderTest method testAddLink_existingLink.

@Test
public void testAddLink_existingLink() throws Exception {
    // Retain current number of edges
    int originalEdgeCount = 0;
    for (Edge e : graph.getEdges()) {
        originalEdgeCount++;
    }
    MetaverseTransientNode node2 = new MetaverseTransientNode();
    node2.setStringID("nodeToId");
    node2.setName("to name");
    MetaverseLink link = new MetaverseLink(node, "uses", node2);
    builder.addLink(link);
    Vertex fromResult = graph.getVertex(node.getStringID());
    Vertex toResult = graph.getVertex(node2.getStringID());
    // make sure the edge exits before we try to add it again
    assertNotNull(graph.getEdge(builder.getEdgeId(fromResult, link.getLabel(), toResult)));
    // make sure we only added 1
    int count = 0;
    for (Edge e : graph.getEdges()) {
        count++;
    }
    assertEquals(originalEdgeCount + 1, count);
    // now lets add it again
    builder.addLink(link);
    // make sure we still only have one edge
    count = 0;
    for (Edge e : graph.getEdges()) {
        count++;
    }
    assertEquals(originalEdgeCount + 1, count);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) MetaverseLink(org.pentaho.dictionary.MetaverseLink) IMetaverseLink(org.pentaho.metaverse.api.IMetaverseLink) Edge(com.tinkerpop.blueprints.Edge) Test(org.junit.Test)

Example 13 with MetaverseTransientNode

use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.

the class MetaverseObjectFactory method createNodeObject.

@Override
public IMetaverseNode createNodeObject(String id) {
    MetaverseTransientNode node = new MetaverseTransientNode();
    node.setStringID(id);
    node.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DEFAULT);
    node.setProperty(DictionaryConst.NODE_VIRTUAL, true);
    return node;
}
Also used : MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode)

Example 14 with MetaverseTransientNode

use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.

the class StepAnalyzerTest method testCreateInputFieldNode.

@Test
public void testCreateInputFieldNode() throws Exception {
    doReturn("thisStepName").when(analyzer).getStepName();
    MetaverseTransientNode node = new MetaverseTransientNode("node id");
    doReturn(node).when(analyzer).createNodeFromDescriptor(any(IComponentDescriptor.class));
    ValueMetaInterface vmi = new ValueMeta("name", 1);
    IMetaverseNode inputFieldNode = analyzer.createInputFieldNode(descriptor.getContext(), vmi, "thisStepName", DictionaryConst.NODE_TYPE_TRANS_FIELD);
    assertNotNull(inputFieldNode);
    assertNotNull(inputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
    assertEquals("thisStepName", inputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
    // the input node should not be added by this step
    verify(builder, never()).addNode(inputFieldNode);
}
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 15 with MetaverseTransientNode

use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.

the class StepAnalyzerTest method testCreateFieldNode_virtual.

@Test
public void testCreateFieldNode_virtual() 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", false);
    assertNotNull(fieldNode);
    assertNotNull(fieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
    assertEquals("nextStep", fieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
    // make sure it did not added to the graph
    verify(builder, never()).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)

Aggregations

MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)18 Test (org.junit.Test)13 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)9 ValueMeta (org.pentaho.di.core.row.ValueMeta)5 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)5 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)5 Vertex (com.tinkerpop.blueprints.Vertex)4 Edge (com.tinkerpop.blueprints.Edge)3 Before (org.junit.Before)3 MetaverseLink (org.pentaho.dictionary.MetaverseLink)3 IMetaverseLink (org.pentaho.metaverse.api.IMetaverseLink)3 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)3 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 HashSet (java.util.HashSet)1 StepField (org.pentaho.metaverse.api.StepField)1 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)1