Search in sources :

Example 6 with MetaverseTransientNode

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

the class MetaverseBuilderTest method testAddLink_OneExistingNode.

@Test
public void testAddLink_OneExistingNode() {
    // explicitly add the fromNode
    builder.addNode(node);
    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());
    // we added this node explicitly through the addNode, it should be flagged as NOT virtual
    assertFalse((Boolean) fromResult.getProperty(DictionaryConst.NODE_VIRTUAL));
    // we added this node implicitly through the addLink, it should be flagged as virtual
    assertTrue((Boolean) toResult.getProperty(DictionaryConst.NODE_VIRTUAL));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) MetaverseLink(org.pentaho.dictionary.MetaverseLink) IMetaverseLink(org.pentaho.metaverse.api.IMetaverseLink) Test(org.junit.Test)

Example 7 with MetaverseTransientNode

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

the class MetaverseBuilderTest method testAddLink.

@Test
public void testAddLink() {
    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());
    // we added this node implicitly through the addLink, it should be flagged as virtual
    assertTrue((Boolean) fromResult.getProperty(DictionaryConst.NODE_VIRTUAL));
    // we added this node implicitly through the addLink, it should be flagged as virtual
    assertTrue((Boolean) toResult.getProperty(DictionaryConst.NODE_VIRTUAL));
    assertNotNull(fromResult.getEdges(Direction.OUT, "uses"));
    for (Edge e : fromResult.getEdges(Direction.OUT, "uses")) {
        assertEquals(e.getVertex(Direction.OUT).getProperty("name"), node.getName());
        assertEquals(e.getVertex(Direction.IN).getProperty("name"), node2.getName());
        // we added this node implicitly through the addLink, it should be flagged as virtual
        assertTrue((Boolean) e.getVertex(Direction.OUT).getProperty(DictionaryConst.NODE_VIRTUAL));
    }
    assertNotNull(toResult.getEdges(Direction.IN, "uses"));
    for (Edge e : fromResult.getEdges(Direction.IN, "uses")) {
        assertEquals(e.getVertex(Direction.OUT).getProperty("name"), node.getName());
        assertEquals(e.getVertex(Direction.IN).getProperty("name"), node2.getName());
        // we added this node implicitly through the addLink, it should be flagged as virtual
        assertTrue((Boolean) e.getVertex(Direction.IN).getProperty(DictionaryConst.NODE_VIRTUAL));
    }
}
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 8 with MetaverseTransientNode

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

the class MetaverseObjectFactory method createNodeObject.

@Override
public IMetaverseNode createNodeObject(INamespace namespace, ILogicalIdGenerator idGenerator, Map<String, Object> properties) {
    MetaverseTransientNode node = new MetaverseTransientNode();
    node.setProperties(properties);
    node.setProperty(DictionaryConst.PROPERTY_NAMESPACE, namespace.getNamespaceId());
    node.setLogicalIdGenerator(idGenerator);
    node.setProperty(DictionaryConst.NODE_VIRTUAL, true);
    String id = node.getLogicalId();
    node.setStringID(id);
    return node;
}
Also used : MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode)

Example 9 with MetaverseTransientNode

use of org.pentaho.dictionary.MetaverseTransientNode 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 10 with MetaverseTransientNode

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

the class JobJobEntryAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    when(metaverseBuilder.getMetaverseObjectFactory()).thenReturn(objectFactory);
    when(objectFactory.createNodeObject(anyString(), anyString(), anyString())).thenReturn(new MetaverseTransientNode("name"));
    when(jobEntryJob.getName()).thenReturn("job entry");
    when(jobEntryJob.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.FILENAME);
    when(jobEntryJob.getFilename()).thenReturn(TEST_FILE_NAME);
    when(jobEntryJob.getParentJob()).thenReturn(mockParentJob);
    when(mockParentJob.getJobMeta()).thenReturn(mockParentJobMeta);
    when(namespace.getParentNamespace()).thenReturn(namespace);
    when(mockParentJobMeta.environmentSubstitute(anyString())).thenAnswer(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            return (String) invocation.getArguments()[0];
        }
    });
    descriptor = new MetaverseComponentDescriptor("job entry", DictionaryConst.NODE_TYPE_JOB_ENTRY, namespace);
    analyzer = new JobJobEntryAnalyzer();
    spyAnalyzer = spy(analyzer);
    spyAnalyzer.setMetaverseBuilder(metaverseBuilder);
    spyAnalyzer.setDescriptor(descriptor);
    doReturn(childJobMeta).when(spyAnalyzer).getSubJobMeta(anyString());
}
Also used : MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Matchers.anyString(org.mockito.Matchers.anyString) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

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