Search in sources :

Example 1 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 2 with MetaverseTransientNode

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

the class TableOutputStepAnalyzerTest method testCustomAnalyze.

@Test
public void testCustomAnalyze() throws Exception {
    when(meta.truncateTable()).thenReturn(true);
    IMetaverseNode node = new MetaverseTransientNode("new node");
    analyzer.customAnalyze(meta, node);
    assertNotNull(node);
    assertTrue((Boolean) node.getProperty(TableOutputStepAnalyzer.TRUNCATE_TABLE));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) Test(org.junit.Test)

Example 3 with MetaverseTransientNode

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

the class TransJobEntryAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    when(metaverseBuilder.getMetaverseObjectFactory()).thenReturn(objectFactory);
    when(objectFactory.createNodeObject(anyString(), anyString(), anyString())).thenReturn(new MetaverseTransientNode("name"));
    when(jobEntryTrans.getName()).thenReturn("job entry");
    when(jobEntryTrans.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.FILENAME);
    when(jobEntryTrans.getFilename()).thenReturn(TEST_FILE_NAME);
    when(jobEntryTrans.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 TransJobEntryAnalyzer();
    spyAnalyzer = spy(analyzer);
    spyAnalyzer.setMetaverseBuilder(metaverseBuilder);
    spyAnalyzer.setDescriptor(descriptor);
    doReturn(childTransMeta).when(spyAnalyzer).getSubTransMeta(anyString());
    doReturn(documentDescriptor).when(spyAnalyzer).getDocumentDescriptor();
}
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)

Example 4 with MetaverseTransientNode

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

the class MongoDbInputStepAnalyzerTest method testCustomAnalyze_jsonOutput.

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

Example 5 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)

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 ClonableStepAnalyzerTest (org.pentaho.metaverse.analyzer.kettle.step.ClonableStepAnalyzerTest)2 HashSet (java.util.HashSet)1 StepField (org.pentaho.metaverse.api.StepField)1 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)1