use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testValueMapperStepNode_overwrite.
@Test
public void testValueMapperStepNode_overwrite() throws Exception {
TransformationStepNode valueMapperStepNode = root.getStepNode("value_mapper", "Value Mapper - overwrite");
assertEquals(1, getIterableSize(valueMapperStepNode.getStreamFieldNodesUses()));
StreamFieldNode usesNode = valueMapperStepNode.getStreamFieldNodesUses().iterator().next();
ValueMapperMeta meta = (ValueMapperMeta) getStepMeta(valueMapperStepNode);
assertEquals(meta.getFieldToUse(), usesNode.getName());
Iterable<StreamFieldNode> inFields = valueMapperStepNode.getInputStreamFields();
int countInputs = getIterableSize(inFields);
Iterable<StreamFieldNode> outFields = valueMapperStepNode.getOutputStreamFields();
int countOutputs = getIterableSize(outFields);
assertEquals(countInputs, countOutputs);
for (StreamFieldNode outField : outFields) {
assertNotNull(outField.getKettleType());
if (outField.getName().equals(meta.getTargetField())) {
Operations ops = MetaverseUtil.convertOperationsStringToMap(usesNode.getOperations());
List<IOperation> dataOps = ops.get(ChangeType.DATA);
assertNotNull(dataOps);
assertEquals(meta.getSourceValue().length, dataOps.size());
for (int i = 0; i < dataOps.size(); i++) {
IOperation dataOp = dataOps.get(i);
assertEquals(DictionaryConst.PROPERTY_TRANSFORMS, dataOp.getName());
assertEquals(dataOp.toString(), meta.getSourceValue()[i] + " -> " + meta.getTargetValue()[i]);
}
// there should not be any metadata operations
assertNull(ops.get(ChangeType.METADATA));
}
}
int derivedCount = getIterableSize(usesNode.getFieldNodesDerivedFromMe());
assertEquals(1, derivedCount);
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testExcelInputStep.
@Test
public void testExcelInputStep() throws Exception {
// this is testing a specific TextFileInputStep instance
ExcelInputStepNode excelInputStepNode = root.getExcelInputStepNode();
assertNotNull(excelInputStepNode);
Iterable<FramedMetaverseNode> inputFiles = excelInputStepNode.getInputFiles();
int countInputFiles = getIterableSize(inputFiles);
assertEquals(1, countInputFiles);
for (FramedMetaverseNode inputFile : inputFiles) {
assertTrue(inputFile.getName().endsWith("SacramentoCrime.xls"));
}
assertEquals("Microsoft Excel Input", excelInputStepNode.getStepType());
int countUses = getIterableSize(excelInputStepNode.getFileFieldNodesUses());
int countInputs = getIterableSize(excelInputStepNode.getInputStreamFields());
assertEquals(0, countUses);
int fileFieldCount = 0;
Iterable<StreamFieldNode> outFields = excelInputStepNode.getOutputStreamFields();
int countOutputs = getIterableSize(outFields);
for (StreamFieldNode outField : outFields) {
assertNotNull(outField.getKettleType());
FieldNode fieldPopulatesMe = outField.getFieldPopulatesMe();
assertNotNull(fieldPopulatesMe);
assertEquals(DictionaryConst.NODE_TYPE_FILE_FIELD, fieldPopulatesMe.getType());
assertEquals(excelInputStepNode, fieldPopulatesMe.getStepThatInputsMe());
fileFieldCount++;
}
assertEquals(countInputs, fileFieldCount);
assertEquals(countOutputs, fileFieldCount);
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testStringsCutStepNode.
@Test
public void testStringsCutStepNode() throws Exception {
TransformationStepNode node = root.getStepNode("strings_cut", "Strings cut");
// Make sure we have the right number of links used, created and derived. Also,
// Ensure there is an entry in the operations for those fields that are derived.
assertEquals(3, getIterableSize(node.getInputStreamFields()));
assertEquals(3, getIterableSize(node.getStreamFieldNodesUses()));
assertEquals(4, getIterableSize(node.getOutputStreamFields()));
for (StreamFieldNode sfn : node.getOutputStreamFields()) {
// "Last Name" is a special case for this test, it is passthrough
if (sfn.getName().equals("Middle Name")) {
assertTrue(Const.isEmpty(sfn.getOperations()));
} else {
assertFalse(Const.isEmpty(sfn.getOperations()));
}
}
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testTableInput.
@Test
public void testTableInput() throws Exception {
TableInputStepNode tableNode = root.getTableInputStepNode();
TableInputMeta meta = (TableInputMeta) getStepMeta(tableNode);
assertNotNull(tableNode);
assertNotNull(tableNode.getDatasource(meta.getDatabaseMeta().getName()));
assertNotNull(tableNode.getDatabaseQueryNode());
assertEquals(meta.getSQL(), tableNode.getDatabaseQueryNode().getQuery());
Iterable<StreamFieldNode> outputStreamFields = tableNode.getOutputStreamFields();
Iterable<DatabaseColumnNode> databaseColumns = tableNode.getDatabaseQueryNode().getDatabaseColumns();
assertEquals(getIterableSize(outputStreamFields), getIterableSize(databaseColumns));
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testHttpClientStep.
@Test
public void testHttpClientStep() throws Exception {
HttpClientStepNode node = root.getHttpClientStepNode();
assertNotNull(node);
Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
int countInputUrls = getIterableSize(inputUrls);
assertEquals(1, countInputUrls);
assertEquals("HTTP Client", node.getStepType());
HTTPMeta stepMeta = (HTTPMeta) getStepMeta(node);
for (FramedMetaverseNode inputUrl : inputUrls) {
assertEquals(stepMeta.getUrl(), inputUrl.getName());
}
// check the param field is "used"
Iterable<StreamFieldNode> streamFieldNodesUses = node.getStreamFieldNodesUses();
assertEquals(2, getIterableSize(streamFieldNodesUses));
Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
assertEquals(5, getIterableSize(outputs));
Iterable<StreamFieldNode> inputs = node.getInputStreamFields();
assertEquals(3, getIterableSize(inputs));
for (StreamFieldNode in : inputs) {
assertNotNull(in.getFieldNodesDerivedFromMe());
assertEquals(in.getName(), in.getFieldNodesDerivedFromMe().iterator().next().getName());
}
}
Aggregations