use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testTransExecutorStepNode.
@Test
public void testTransExecutorStepNode() throws Exception {
TransExecutorStepNode transExecutorStepNode = root.getTransExecutorStepNode();
assertNotNull(transExecutorStepNode);
TransExecutorMeta meta = (TransExecutorMeta) getStepMeta(transExecutorStepNode);
assertEquals(meta.getParentStepMeta().getName(), transExecutorStepNode.getName());
assertEquals(meta.getOutputRowsSourceStep(), transExecutorStepNode.getOutputRowsTargetStepName());
assertEquals(meta.getResultFilesTargetStep(), transExecutorStepNode.getResultFilesTargetStepName());
assertEquals(meta.getExecutionResultTargetStep(), transExecutorStepNode.getExecutionResultsTargetStepName());
assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getOutputRowsSourceStep()));
assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getResultFilesTargetStep()));
assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getExecutionResultTargetStep()));
RowMetaInterface incomingRow = meta.getParentStepMeta().getParentTransMeta().getPrevStepFields(meta.getParentStepMeta());
int incomingFieldCount = incomingRow.size();
Iterable<StreamFieldNode> streamFieldNodes = transExecutorStepNode.getOutputStreamFields();
int countOutputStreamFieldNode = getIterableSize(streamFieldNodes);
List<String> outputFields = Arrays.asList(meta.getOutputRowsField());
for (StreamFieldNode streamFieldNode : streamFieldNodes) {
assertNotNull(streamFieldNode.getKettleType());
if (outputFields.contains(streamFieldNode.getName())) {
// this field came back to us from the sub trans via a result, lets make sure they link up
assertEquals(transExecutorStepNode.getTransToExecute(), streamFieldNode.getFieldNodesThatDeriveMe().iterator().next().getStepThatOutputsMe().getTransNode());
}
}
streamFieldNodes = transExecutorStepNode.getStreamFieldNodesDeletes();
int countDeletedStreamFieldNode = getIterableSize(streamFieldNodes);
for (StreamFieldNode streamFieldNode : streamFieldNodes) {
assertNotNull(streamFieldNode.getKettleType());
}
assertNotNull(transExecutorStepNode.getTransToExecute());
streamFieldNodes = transExecutorStepNode.getStreamFieldNodesUses();
int countUsedStreamFieldNode = getIterableSize(streamFieldNodes);
for (StreamFieldNode streamFieldNode : streamFieldNodes) {
assertNotNull(streamFieldNode.getKettleType());
// these should link up to stream fields in the sub trans via the "get rows from result" step
for (StreamFieldNode derived : streamFieldNode.getFieldNodesDerivedFromMe()) {
// the trans that is to be executed should contain the step that creates a field derived from the incoming field
assertEquals(transExecutorStepNode.getTransToExecute(), derived.getStepThatInputsMe().getTransNode());
}
}
assertEquals(incomingFieldCount, countUsedStreamFieldNode);
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testMongoDbInput.
@Test
public void testMongoDbInput() throws Exception {
MongoDbInputStepNode node = root.getMongoDbInputStepNode();
assertNotNull(node);
MongoDbMeta meta = (MongoDbMeta) getStepMeta(node);
assertEquals(meta.getCollection(), node.getCollection().getName());
assertEquals(meta.getDbName(), node.getDatasource(meta.getDbName()).getName());
Iterable<StreamFieldNode> inputs = node.getInputStreamFields();
Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
assertEquals(getIterableSize(inputs), getIterableSize(outputs));
for (StreamFieldNode output : outputs) {
assertEquals(output.getName(), output.getFieldPopulatesMe().getName());
}
MongoConnectionNode datasource = node.getDatasource(meta.getDbName());
assertEquals(meta.getHostnames(), datasource.getHost());
assertEquals(meta.getPort(), datasource.getPort());
assertEquals(meta.getAuthenticationUser(), datasource.getUserName());
assertEquals(meta.getDbName(), datasource.getDatabaseName());
assertEquals(DictionaryConst.NODE_TYPE_MONGODB_CONNECTION, datasource.getType());
FramedMetaverseNode collection = node.getCollection();
assertEquals(meta.getCollection(), collection.getName());
assertEquals(DictionaryConst.NODE_TYPE_MONGODB_COLLECTION, collection.getType());
}
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()));
}
}
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testValueMapperStepNode_newField.
@Test
public void testValueMapperStepNode_newField() throws Exception {
TransformationStepNode valueMapperStepNode = root.getStepNode("value_mapper", "Value Mapper - new field");
assertEquals(1, getIterableSize(valueMapperStepNode.getStreamFieldNodesUses()));
StreamFieldNode usesNode = valueMapperStepNode.getStreamFieldNodesUses().iterator().next();
ValueMapperMeta meta = (ValueMapperMeta) getStepMeta(valueMapperStepNode);
assertEquals(meta.getFieldToUse(), usesNode.getName());
assertNull(usesNode.getOperations());
Iterable<StreamFieldNode> inFields = valueMapperStepNode.getInputStreamFields();
int countInputs = getIterableSize(inFields);
Iterable<StreamFieldNode> outFields = valueMapperStepNode.getOutputStreamFields();
int countOutputs = getIterableSize(outFields);
assertEquals(countInputs + 1, countOutputs);
for (StreamFieldNode outField : outFields) {
assertNotNull(outField.getKettleType());
if (outField.getName().equals(meta.getTargetField())) {
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(1, dataOps.size());
for (IOperation dataOp : dataOps) {
assertEquals(Operation.MAPPING_CATEGORY, dataOp.getCategory());
assertEquals(DictionaryConst.PROPERTY_TRANSFORMS, dataOp.getName());
}
// 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 testStringsReplaceStepNode.
@Test
public void testStringsReplaceStepNode() throws Exception {
TransformationStepNode node = root.getStepNode("strings_replace", "Replace in string");
// 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(5, getIterableSize(node.getInputStreamFields()));
assertEquals(5, getIterableSize(node.getStreamFieldNodesUses()));
assertEquals(10, getIterableSize(node.getOutputStreamFields()));
for (StreamFieldNode sfn : node.getOutputStreamFields()) {
// The following are special cases for this test, they are passthrough fields
if (sfn.getName().equals("LastName") || sfn.getName().equals("FirstName") || sfn.getName().equals("NickName") || sfn.getName().equals("Template")) {
assertTrue(Const.isEmpty(sfn.getOperations()));
} else {
assertFalse(Const.isEmpty(sfn.getOperations()));
}
}
}
Aggregations