Search in sources :

Example 6 with StepNodes

use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes in project pentaho-metaverse by pentaho.

the class TextFileOutputStepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace);
    descriptor = new MetaverseComponentDescriptor("test", DictionaryConst.NODE_TYPE_TRANS_STEP, mockNamespace);
    analyzer = spy(new TextFileOutputStepAnalyzer());
    analyzer.setDescriptor(descriptor);
    analyzer.setObjectFactory(MetaverseTestUtils.getMetaverseObjectFactory());
    inputs = new StepNodes();
    inputs.addNode("previousStep", "first", node);
    inputs.addNode("previousStep", "last", node);
    inputs.addNode("previousStep", "age", node);
    inputs.addNode("previousStep", "filename", node);
    doReturn(inputs).when(analyzer).getInputs();
}
Also used : StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

Example 7 with StepNodes

use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes in project pentaho-metaverse by pentaho.

the class TransExecutorStepAnalyzerTest method testConnectToSubTransInputFields.

@Test
public void testConnectToSubTransInputFields() throws Exception {
    IMetaverseNode childTransNode = mock(IMetaverseNode.class);
    IMetaverseNode outNode = mock(IMetaverseNode.class);
    StepNodes inputs = new StepNodes();
    inputs.addNode("previousStep", "first", outNode);
    inputs.addNode("previousStep", "last", outNode);
    doReturn(inputs).when(spyAnalyzer).getInputs();
    doNothing().when(spyAnalyzer).linkUsedFieldToSubTrans(any(IMetaverseNode.class), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
    spyAnalyzer.connectToSubTransInputFields(meta, childTransMeta, childTransNode, descriptor);
    verify(spyAnalyzer, times(inputs.getFieldNames().size())).linkUsedFieldToSubTrans(any(IMetaverseNode.class), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) Test(org.junit.Test)

Example 8 with StepNodes

use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes in project pentaho-metaverse by pentaho.

the class TransExecutorStepAnalyzerTest method testConnectToSubTransOutputFields_MainOutput.

@Test
public void testConnectToSubTransOutputFields_MainOutput() throws Exception {
    when(meta.getOutputRowsSourceStep()).thenReturn(null);
    when(meta.getExecutorsOutputStep()).thenReturn("outputRowsStepName");
    String[] outputFields = new String[] { "first", "last" };
    when(meta.getOutputRowsField()).thenReturn(outputFields);
    IMetaverseNode outNode = mock(IMetaverseNode.class);
    StepNodes outputs = new StepNodes();
    outputs.addNode("outputRowsStepName", "first", outNode);
    outputs.addNode("outputRowsStepName", "last", outNode);
    doReturn(outputs).when(spyAnalyzer).getOutputs();
    // we'll test this in it's own test
    doNothing().when(spyAnalyzer).linkResultFieldToSubTrans(any(IMetaverseNode.class), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
    IMetaverseNode childTransNode = mock(IMetaverseNode.class);
    spyAnalyzer.connectToSubTransOutputFields(meta, childTransMeta, childTransNode, descriptor);
    verify(spyAnalyzer, times(outputFields.length)).linkResultFieldToSubTrans(any(IMetaverseNode.class), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Matchers.anyString(org.mockito.Matchers.anyString) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) Test(org.junit.Test)

Example 9 with StepNodes

use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes in project pentaho-metaverse by pentaho.

the class ExcelOutputStepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace);
    descriptor = new MetaverseComponentDescriptor("test", DictionaryConst.NODE_TYPE_TRANS_STEP, mockNamespace);
    analyzer = spy(new ExcelOutputStepAnalyzer());
    analyzer.setDescriptor(descriptor);
    analyzer.setObjectFactory(MetaverseTestUtils.getMetaverseObjectFactory());
    inputs = new StepNodes();
    inputs.addNode("previousStep", "first", node);
    inputs.addNode("previousStep", "last", node);
    inputs.addNode("previousStep", "age", node);
    inputs.addNode("previousStep", "filename", node);
    doReturn(inputs).when(analyzer).getInputs();
}
Also used : StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

Example 10 with StepNodes

use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes in project pentaho-metaverse by pentaho.

the class FilterRowsStepAnalyzerTest method testGetUsedFields.

@Test
public void testGetUsedFields() throws Exception {
    StepNodes inputNodes = new StepNodes();
    inputNodes.addNode("input", "height", node);
    inputNodes.addNode("input", "width", node);
    inputNodes.addNode("input", "radius", node);
    inputNodes.addNode("input", "pi", node);
    inputNodes.addNode("input", "two", node);
    when(analyzer.getInputs()).thenReturn(inputNodes);
    Set<StepField> usedFields = analyzer.getUsedFields(meta);
    assertNotNull(usedFields);
    assertEquals(conditionFields.length, usedFields.size());
}
Also used : StepField(org.pentaho.metaverse.api.StepField) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) Test(org.junit.Test)

Aggregations

StepNodes (org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes)17 Test (org.junit.Test)10 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)7 Before (org.junit.Before)6 StepField (org.pentaho.metaverse.api.StepField)5 Matchers.anyString (org.mockito.Matchers.anyString)4 TransMeta (org.pentaho.di.trans.TransMeta)4 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)4 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)4 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)2 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)2 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 SelectMetadataChange (org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange)1