use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testSelectValuesStep.
@Test
public void testSelectValuesStep() throws Exception {
// this tests a specific select values step. the one in trans "Populate Table From File"
SelectValuesTransStepNode selectValues = root.getSelectValuesStepNode();
assertNotNull(selectValues);
int countUses = getIterableSize(selectValues.getStreamFieldNodesUses());
int countOutputs = getIterableSize(selectValues.getOutputStreamFields());
int countInputs = getIterableSize(selectValues.getInputStreamFields());
assertEquals(9, countUses);
SelectValuesMeta meta = (SelectValuesMeta) getStepMeta(selectValues);
assertEquals(getExpectedOutputFieldCount(meta), countOutputs);
assertEquals(9, countInputs);
assertEquals("Select values", selectValues.getStepType());
for (StreamFieldNode node : selectValues.getOutputStreamFields()) {
// check for operations
if (node.getOperations() != null) {
Operations ops = MetaverseUtil.convertOperationsStringToMap(node.getOperations());
assertNotNull(ops);
List<IOperation> metadataOps = ops.get(ChangeType.METADATA);
assertNotNull(metadataOps);
assertTrue(metadataOps.size() > 0);
// there should not be any data operations on nodes touched by this step
assertNull(ops.get(ChangeType.DATA));
}
// check the created node is derived from something
Iterable<StreamFieldNode> deriveNodes = node.getFieldNodesThatDeriveMe();
for (StreamFieldNode deriveNode : deriveNodes) {
assertNotNull(deriveNode);
}
}
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testTableOutputStepNode.
@Test
public void testTableOutputStepNode() throws Exception {
// this tests a specific step in a specific transform
TableOutputStepNode node = root.getTableOutputStepNode();
// check the table that it writes to
TableOutputMeta meta = (TableOutputMeta) getStepMeta(node);
String tableName = meta.getTableName();
String schema = meta.getSchemaName();
boolean truncateTable = meta.truncateTable();
DatabaseTableNode databaseTableNode = node.getDatabaseTable();
assertEquals(tableName, databaseTableNode.getName());
assertEquals(schema, node.getSchema());
assertEquals(truncateTable, node.isTruncateTable());
Iterable<StreamFieldNode> inputs = node.getInputStreamFields();
Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
assertEquals(getIterableSize(inputs) + meta.getFieldDatabase().length, getIterableSize(outputs));
for (StreamFieldNode input : inputs) {
assertEquals(input.getName(), input.getFieldPopulatedByMe().getName());
}
DatasourceNode datasource = node.getDatasource(meta.getDatabaseMeta().getName());
assertEquals(meta.getDatabaseMeta().getHostname(), datasource.getHost());
assertEquals(meta.getDatabaseMeta().getDatabasePortNumberString(), datasource.getPort());
assertEquals(meta.getDatabaseMeta().getUsername(), datasource.getUserName());
assertEquals(meta.getDatabaseMeta().getDatabaseName(), datasource.getDatabaseName());
assertEquals(DictionaryConst.NODE_TYPE_DATASOURCE, datasource.getType());
assertEquals(meta.getTableName(), databaseTableNode.getName());
assertEquals(DictionaryConst.NODE_TYPE_DATA_TABLE, databaseTableNode.getType());
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testNumberRangeStepNode_newField.
@Test
public void testNumberRangeStepNode_newField() throws Exception {
TransformationStepNode numberRangeStepNode = root.getStepNode("number_range", "Number range");
assertEquals(1, getIterableSize(numberRangeStepNode.getStreamFieldNodesUses()));
StreamFieldNode usesNode = null;
for (StreamFieldNode node : numberRangeStepNode.getStreamFieldNodesUses()) {
usesNode = node;
break;
}
NumberRangeMeta meta = (NumberRangeMeta) getStepMeta(numberRangeStepNode);
assertEquals(meta.getInputField(), usesNode.getName());
assertNull(usesNode.getOperations());
Iterable<StreamFieldNode> outFields = numberRangeStepNode.getOutputStreamFields();
int countOutputs = getIterableSize(outFields);
assertEquals(2, countOutputs);
for (StreamFieldNode outField : outFields) {
assertNotNull(outField.getKettleType());
if (outField.getName().equals(meta.getOutputField())) {
Iterable<StreamFieldNode> fieldNodesThatDeriveMe = outField.getFieldNodesThatDeriveMe();
assertNotNull(fieldNodesThatDeriveMe);
int derivesCount = getIterableSize(outField.getFieldNodesThatDeriveMe());
assertEquals(1, derivesCount);
for (FieldNode derives : outField.getFieldNodesThatDeriveMe()) {
assertEquals(usesNode.getName(), derives.getName());
assertEquals(usesNode.getType(), derives.getType());
}
Operations ops = MetaverseUtil.convertOperationsStringToMap(outField.getOperations());
List<IOperation> dataOps = ops.get(ChangeType.DATA);
assertNotNull(dataOps);
assertEquals(3, dataOps.size());
for (IOperation dataOp : dataOps) {
assertEquals(Operation.MAPPING_CATEGORY, dataOp.getCategory());
assertEquals(DictionaryConst.PROPERTY_TRANSFORMS, dataOp.getName());
assertTrue(dataOp.toString().contains(meta.getInputField()));
}
// there should not be any metadata operations
assertNull(ops.get(ChangeType.METADATA));
}
}
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testTextFileOutputStepNode.
@Test
public void testTextFileOutputStepNode() throws Exception {
TextFileOutputStepNode textFileOutputStepNode = root.getTextFileOutputStepNode("textFileOutput", "Text file output");
TextFileOutputMeta meta = (TextFileOutputMeta) getStepMeta(textFileOutputStepNode);
TransMeta tm = meta.getParentStepMeta().getParentTransMeta();
String[] fileNames = meta.getFiles(tm);
RowMetaInterface incomingFields = tm.getPrevStepFields(meta.getParentStepMeta());
int outputFields = getExpectedOutputFieldCount(meta);
assertNotNull(textFileOutputStepNode);
Iterable<StreamFieldNode> outFields = textFileOutputStepNode.getOutputStreamFields();
int outFieldCount = getIterableSize(outFields);
// should have output stream nodes as well as file nodes
assertEquals(outputFields + meta.getOutputFields().length, outFieldCount);
int fileFieldCount = 0;
for (StreamFieldNode outField : outFields) {
if (DictionaryConst.NODE_TYPE_FILE_FIELD.equals(outField.getType())) {
ValueMetaInterface vmi = incomingFields.searchValueMeta(outField.getName());
assertEquals(vmi.getName(), outField.getFieldPopulatesMe().getName());
fileFieldCount++;
}
}
assertEquals(fileFieldCount, outFieldCount / 2);
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testStringOperationsStepNode.
@Test
public void testStringOperationsStepNode() throws Exception {
TransformationStepNode node = root.getStepNode("string_operations", "String operations");
// Make sure we have the right number of links used
assertEquals(4, getIterableSize(node.getInputStreamFields()));
assertEquals(4, getIterableSize(node.getStreamFieldNodesUses()));
assertEquals(5, getIterableSize(node.getOutputStreamFields()));
for (StreamFieldNode sfn : node.getOutputStreamFields()) {
// "Last Name" is a special case for this test, it is passthrough
if (sfn.getName().equals("Last Name")) {
assertTrue(Const.isEmpty(sfn.getOperations()));
} else {
assertFalse(Const.isEmpty(sfn.getOperations()));
}
}
}
Aggregations