use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzerTest method testCreateOutputFieldNode.
@Test
public void testCreateOutputFieldNode() throws Exception {
IAnalysisContext context = mock(IAnalysisContext.class);
ValueMetaInterface vmi = new ValueMeta("field1");
MongoField mongoField1 = new MongoField();
mongoField1.m_fieldName = "field1";
mongoField1.m_fieldPath = "$.field1";
mongoField1.m_arrayIndexInfo = "range";
mongoField1.m_occurenceFraction = "occurence";
mongoField1.m_indexedVals = Arrays.asList(new String[] { "one", "two" });
mongoField1.m_disparateTypes = true;
mongoField1.m_kettleType = "ValueMetaString";
mongoField1.m_outputIndex = 0;
List<MongoField> mongoFields = Arrays.asList(mongoField1);
when(meta.getMongoFields()).thenReturn(mongoFields);
doReturn("thisStepName").when(analyzer).getStepName();
when(node.getLogicalId()).thenReturn("logical id");
IMetaverseNode node = analyzer.createOutputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(node);
assertEquals("field1", node.getName());
assertEquals(mongoField1.m_fieldPath, node.getProperty(MongoDbInputStepAnalyzer.JSON_PATH));
assertEquals(mongoField1.m_arrayIndexInfo, node.getProperty(MongoDbInputStepAnalyzer.MINMAX_RANGE));
assertEquals(mongoField1.m_occurenceFraction, node.getProperty(MongoDbInputStepAnalyzer.OCCUR_RATIO));
assertEquals(mongoField1.m_indexedVals, node.getProperty(MongoDbInputStepAnalyzer.INDEXED_VALS));
assertEquals(mongoField1.m_disparateTypes, node.getProperty(MongoDbInputStepAnalyzer.DISPARATE_TYPES));
}
use of org.pentaho.metaverse.api.IMetaverseNode 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));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TransExecutorStepAnalyzerTest method testConnectResultFieldToSubTrans_noChildTransSteps.
@Test
public void testConnectResultFieldToSubTrans_noChildTransSteps() throws Exception {
IMetaverseNode childTransNode = mock(IMetaverseNode.class);
IMetaverseNode rootNode = mock(IMetaverseNode.class);
when(childTransMeta.getSteps()).thenReturn(null);
spyAnalyzer.linkResultFieldToSubTrans(rootNode, childTransMeta, childTransNode, descriptor);
verify(builder, never()).addLink(any(IMetaverseNode.class), eq(DictionaryConst.LINK_DERIVES), any(IMetaverseNode.class));
}
use of org.pentaho.metaverse.api.IMetaverseNode 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));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TransExecutorStepAnalyzerTest method testLinkUsedFieldToSubTrans.
@Test
public void testLinkUsedFieldToSubTrans() throws Exception {
IMetaverseNode childTransNode = mock(IMetaverseNode.class);
IMetaverseNode originalFieldNode = mock(IMetaverseNode.class);
when(originalFieldNode.getName()).thenReturn(resultsFieldNames[1]);
List<StepMeta> childTransSteps = new ArrayList<StepMeta>();
StepMeta dummy = mock(StepMeta.class);
when(dummy.getStepMetaInterface()).thenReturn(mock(DummyTransMeta.class));
childTransSteps.add(dummy);
StepMeta rowsFromResult = mock(StepMeta.class);
RowsFromResultMeta mockRowsFromResultMeta = mock(RowsFromResultMeta.class);
when(rowsFromResult.getStepMetaInterface()).thenReturn(mockRowsFromResultMeta);
when(rowsFromResult.getName()).thenReturn("stepName");
childTransSteps.add(rowsFromResult);
when(mockRowsFromResultMeta.getFieldname()).thenReturn(resultsFieldNames);
StepMeta rowsParentStepMeta = mock(StepMeta.class);
TransMeta rowsParentTransMeta = mock(TransMeta.class);
RowMetaInterface rmiRows = mock(RowMetaInterface.class);
when(mockRowsFromResultMeta.getParentStepMeta()).thenReturn(rowsParentStepMeta);
when(rowsParentStepMeta.getParentTransMeta()).thenReturn(rowsParentTransMeta);
when(rowsParentTransMeta.getStepFields(rowsFromResult)).thenReturn(rmiRows);
when(rmiRows.getFieldNames()).thenReturn(resultsFieldNames);
ValueMetaInterface vmi = mock(ValueMetaInterface.class);
when(rmiRows.getValueMeta(anyInt())).thenReturn(vmi);
when(childTransMeta.getSteps()).thenReturn(childTransSteps);
IMetaverseNode subFieldNode = mock(IMetaverseNode.class);
doReturn(subFieldNode).when(spyAnalyzer).createFieldNode(any(IComponentDescriptor.class), any(ValueMetaInterface.class), eq("stepName"), eq(false));
spyAnalyzer.linkUsedFieldToSubTrans(originalFieldNode, childTransMeta, childTransNode, descriptor);
verify(spyAnalyzer).createFieldNode(any(IComponentDescriptor.class), any(ValueMetaInterface.class), eq("stepName"), eq(false));
verify(builder).addLink(eq(originalFieldNode), eq(DictionaryConst.LINK_DERIVES), eq(subFieldNode));
}
Aggregations