use of org.pentaho.di.core.row.ValueMeta in project pdi-dataservice-server-plugin by pentaho.
the class MongodbPredicateTest method setup.
@Before
public void setup() {
for (int i = 0; i < 10; i++) {
rowMeta.addValueMeta(new ValueMeta("sField" + i, ValueMetaInterface.TYPE_STRING, 50));
rowMeta.addValueMeta(new ValueMeta("iField" + i, ValueMetaInterface.TYPE_INTEGER, 7));
}
resolver = new ValueMetaResolver(rowMeta);
fieldMappings = new HashMap<String, String>();
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzerTest method testCreateOutputFieldNode_noFields.
@Test
public void testCreateOutputFieldNode_noFields() throws Exception {
ValueMetaInterface vmi = new ValueMeta("field1");
IAnalysisContext context = mock(IAnalysisContext.class);
when(meta.getMongoFields()).thenReturn(null);
doReturn("thisStepName").when(analyzer).getStepName();
when(node.getLogicalId()).thenReturn("logical id");
IMetaverseNode node = analyzer.createOutputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertEquals("field1", node.getName());
assertNull(node.getProperty(MongoDbInputStepAnalyzer.JSON_PATH));
assertNull(node.getProperty(MongoDbInputStepAnalyzer.MINMAX_RANGE));
assertNull(node.getProperty(MongoDbInputStepAnalyzer.OCCUR_RATIO));
assertNull(node.getProperty(MongoDbInputStepAnalyzer.INDEXED_VALS));
assertNull(node.getProperty(MongoDbInputStepAnalyzer.DISPARATE_TYPES));
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzerTest method testCreateOutputFieldNode_resource.
@Test
public void testCreateOutputFieldNode_resource() throws Exception {
IAnalysisContext context = mock(IAnalysisContext.class);
doReturn("thisStepName").when(analyzer).getStepName();
analyzer.rootNode = node;
when(node.getLogicalId()).thenReturn("logical id");
ValueMetaInterface vmi = new ValueMeta("name", 1);
IMetaverseNode outputFieldNode = analyzer.createOutputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(outputFieldNode);
assertNotNull(outputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals(ExternalResourceStepAnalyzer.RESOURCE, outputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
assertEquals("OUTPUT_TYPE", outputFieldNode.getType());
// the input node should be added by this step
verify(builder).addNode(outputFieldNode);
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzerTest method testGetOutputRowMetaInterfaces_isOutput.
@Test
public void testGetOutputRowMetaInterfaces_isOutput() throws Exception {
String[] nextStepNames = new String[] { "nextStep1" };
when(parentTransMeta.getNextStepNames(parentStepMeta)).thenReturn(nextStepNames);
List<ValueMetaInterface> valueMetas = new ArrayList<>();
valueMetas.add(new ValueMeta("field1"));
valueMetas.add(new ValueMeta("field2"));
RowMetaInterface rowMetaInterface = mock(RowMetaInterface.class);
RowMetaInterface clone = mock(RowMetaInterface.class);
when(rowMetaInterface.getValueMetaList()).thenReturn(valueMetas);
when(rowMetaInterface.clone()).thenReturn(clone);
doReturn(rowMetaInterface).when(analyzer).getOutputFields(meta);
doReturn(true).when(analyzer).isOutput();
Set<String> resourceFields = new HashSet<>();
resourceFields.add("field1");
doReturn(resourceFields).when(analyzer).getOutputResourceFields(meta);
Map<String, RowMetaInterface> rowMetaInterfaces = analyzer.getOutputRowMetaInterfaces(meta);
assertNotNull(rowMetaInterfaces);
// should have the normal rmi as well as the resource ones
assertEquals(nextStepNames.length * 2, rowMetaInterfaces.size());
assertEquals(rowMetaInterface, rowMetaInterfaces.get(nextStepNames[0]));
// field 2 isn't one of the fields written to the resource, it should be removed from the cloned RowMetaInterface
verify(clone).removeValueMeta("field2");
// field 1 is one of the fields written to the resource, it should not be removed from the cloned RowMetaInterface
verify(clone, never()).removeValueMeta("field1");
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzerTest method testCreateOutputFieldNode.
@Test
public void testCreateOutputFieldNode() throws Exception {
IAnalysisContext context = mock(IAnalysisContext.class);
doReturn("thisStepName").when(analyzer).getStepName();
analyzer.rootNode = node;
when(node.getLogicalId()).thenReturn("logical id");
ValueMetaInterface vmi = new ValueMeta("name", 1);
IMetaverseNode outputFieldNode = analyzer.createOutputFieldNode(context, vmi, "targetStep", DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(outputFieldNode);
assertNotNull(outputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("targetStep", outputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
assertEquals(DictionaryConst.NODE_TYPE_TRANS_FIELD, outputFieldNode.getType());
// the input node should be added by this step
verify(builder).addNode(outputFieldNode);
}
Aggregations