use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testHttpPostStep.
@Test
public void testHttpPostStep() throws Exception {
// this is testing a specific TextFileInputStep instance
HttpPostStepNode node = root.getHttpPostStepNode();
assertNotNull(node);
Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
int countUrls = getIterableSize(inputUrls);
assertEquals(1, countUrls);
for (FramedMetaverseNode inputUrl : inputUrls) {
assertTrue(inputUrl.getName().endsWith("/posts"));
}
assertEquals("HTTP Post", node.getStepType());
// check the param field is "used"
Iterable<StreamFieldNode> streamFieldNodesUses = node.getStreamFieldNodesUses();
assertEquals(1, getIterableSize(streamFieldNodesUses));
Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
assertEquals(3, getIterableSize(outputs));
Iterable<StreamFieldNode> inputs = node.getInputStreamFields();
assertEquals(1, getIterableSize(inputs));
for (StreamFieldNode in : inputs) {
assertNotNull(in.getFieldNodesDerivedFromMe());
assertEquals(in.getName(), in.getFieldNodesDerivedFromMe().iterator().next().getName());
}
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testExcelInputStep_filenameFromField.
@Test
public void testExcelInputStep_filenameFromField() throws Exception {
// this is testing a specific TextFileInputStep instance
ExcelInputStepNode excelInputStepNode = root.getExcelInputFileNameFromFieldStepNode();
assertNotNull(excelInputStepNode);
int countUses = getIterableSize(excelInputStepNode.getFileFieldNodesUses());
int countInputs = getIterableSize(excelInputStepNode.getInputStreamFields());
assertEquals(1, countUses);
int fileFieldCount = 0;
Iterable<StreamFieldNode> outFields = excelInputStepNode.getOutputStreamFields();
int countOutputs = getIterableSize(outFields);
for (StreamFieldNode outField : outFields) {
assertNotNull(outField.getKettleType());
if (!outField.getName().equals("filename")) {
FieldNode fieldPopulatesMe = outField.getFieldPopulatesMe();
assertNotNull(fieldPopulatesMe);
assertEquals(DictionaryConst.NODE_TYPE_FILE_FIELD, fieldPopulatesMe.getType());
assertEquals(excelInputStepNode, fieldPopulatesMe.getStepThatInputsMe());
fileFieldCount++;
}
}
// we should have one more input than file fields since we are reading it off of the input stream
assertEquals(countInputs - 1, fileFieldCount);
assertEquals(countOutputs - 1, fileFieldCount);
String filenameField = null;
TransMeta tm = new TransMeta(new FileInputStream(excelInputStepNode.getTransNode().getPath()), null, true, null, null);
for (StepMeta stepMeta : tm.getSteps()) {
if (stepMeta.getName().equals(excelInputStepNode.getName())) {
ExcelInputMeta meta = (ExcelInputMeta) getBaseStepMetaFromStepMeta(stepMeta);
assertTrue(meta.isAcceptingFilenames());
filenameField = meta.getAcceptingField();
assertNotNull(filenameField);
assertEquals(filenameField, excelInputStepNode.getFileFieldNodesUses().iterator().next().getName());
// this was the one we cared about...
break;
}
}
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testOldTextFileInputStep_filenameFromField.
@Test
public void testOldTextFileInputStep_filenameFromField() throws Exception {
// this is testing a specific TextFileInputStep instance
FileInputStepNode fileInputStepNode = root.getOldTextFileInputStepNode_filenameFromField();
assertNotNull(fileInputStepNode);
int countUses = getIterableSize(fileInputStepNode.getFileFieldNodesUses());
int countInputs = getIterableSize(fileInputStepNode.getInputStreamFields());
assertEquals(1, countUses);
int fileFieldCount = 0;
Iterable<StreamFieldNode> outFields = fileInputStepNode.getOutputStreamFields();
int countOutputs = getIterableSize(outFields);
for (StreamFieldNode outField : outFields) {
assertNotNull(outField.getKettleType());
if (!outField.getName().equals("filename")) {
FieldNode fieldPopulatesMe = outField.getFieldPopulatesMe();
assertNotNull(fieldPopulatesMe);
assertEquals(DictionaryConst.NODE_TYPE_FILE_FIELD, fieldPopulatesMe.getType());
assertEquals(fileInputStepNode, fieldPopulatesMe.getStepThatInputsMe());
fileFieldCount++;
}
}
// we should have one more input than file fields since we are reading it off of the input stream
assertEquals(countInputs - 1, fileFieldCount);
assertEquals(countOutputs, fileFieldCount);
String filenameField = null;
TransMeta tm = new TransMeta(new FileInputStream(fileInputStepNode.getTransNode().getPath()), null, true, null, null);
for (StepMeta stepMeta : tm.getSteps()) {
if (stepMeta.getName().equals(fileInputStepNode.getName())) {
org.pentaho.di.trans.steps.textfileinput.TextFileInputMeta meta = (org.pentaho.di.trans.steps.textfileinput.TextFileInputMeta) getBaseStepMetaFromStepMeta(stepMeta);
assertTrue(meta.isAcceptingFilenames());
filenameField = meta.getAcceptingField();
assertNotNull(filenameField);
assertEquals(filenameField, fileInputStepNode.getFileFieldNodesUses().iterator().next().getName());
// this was the one we cared about...
break;
}
}
}
use of org.pentaho.metaverse.frames.StreamFieldNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testCsvFileInputStep.
@Test
public void testCsvFileInputStep() throws Exception {
// this is testing a specific CsvFileInputStep instance
CsvFileInputStepNode csvFileInputStepNode = root.getCsvFileInputStepNode();
assertNotNull(csvFileInputStepNode);
Iterable<FramedMetaverseNode> inputFiles = csvFileInputStepNode.getInputFiles();
int countInputFiles = getIterableSize(inputFiles);
int countOutputs = getIterableSize(csvFileInputStepNode.getOutputStreamFields());
assertEquals(1, countInputFiles);
assertEquals(10, countOutputs);
for (FramedMetaverseNode inputFile : inputFiles) {
assertTrue(inputFile.getName().endsWith("customers-100.txt"));
}
assertEquals("CSV file input", csvFileInputStepNode.getStepType());
int fileFieldCount = 0;
Iterable<StreamFieldNode> outFields = csvFileInputStepNode.getOutputStreamFields();
for (StreamFieldNode outField : outFields) {
assertNotNull(outField.getKettleType());
FieldNode fieldPopulatesMe = outField.getFieldPopulatesMe();
assertNotNull(fieldPopulatesMe);
assertEquals(DictionaryConst.NODE_TYPE_FILE_FIELD, fieldPopulatesMe.getType());
assertEquals(csvFileInputStepNode, fieldPopulatesMe.getStepThatInputsMe());
fileFieldCount++;
}
assertEquals(countOutputs, fileFieldCount);
}
Aggregations