use of org.pentaho.metaverse.frames.FramedMetaverseNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testExcelOutputStepNode.
@Test
public void testExcelOutputStepNode() throws Exception {
ExcelOutputStepNode excelOutputStepNode = root.getExcelOutputStepNode();
assertNotNull(excelOutputStepNode);
ExcelOutputMeta meta = (ExcelOutputMeta) getStepMeta(excelOutputStepNode);
TransMeta tm = meta.getParentStepMeta().getParentTransMeta();
String[] fileNames = meta.getFiles(tm);
RowMetaInterface incomingFields = tm.getStepFields(meta.getParentStepMeta());
ExcelField[] outputFields = meta.getOutputFields();
// should write to one file
Iterable<FramedMetaverseNode> outputFiles = excelOutputStepNode.getOutputFiles();
assertEquals(fileNames.length, getIterableSize(outputFiles));
int i = 0;
for (FramedMetaverseNode node : outputFiles) {
assertEquals(normalizeFilePath(fileNames[i++]), normalizeFilePath(node.getName()));
}
Iterable<StreamFieldNode> outFields = excelOutputStepNode.getOutputStreamFields();
int outFieldCount = getIterableSize(outFields);
// should have output stream nodes as well as file nodes
assertEquals(outputFields.length * 2, 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.FramedMetaverseNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testHTTPClientStep_UrlFromField.
@Test
public void testHTTPClientStep_UrlFromField() throws Exception {
// this is testing a specific TextFileInputStep instance
HttpClientStepNode node = root.getHttpClientStepNode_urlFromField();
assertNotNull(node);
// this HTTP Client gets it's files from an incoming stream field, there should be no files modeled statically
Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
int countInputUrls = getIterableSize(inputUrls);
// it is coming from a field
assertEquals(0, countInputUrls);
HTTPMeta stepMeta = (HTTPMeta) getStepMeta(node);
assertEquals("HTTP Client", node.getStepType());
Set<String> usedFields = new HashSet<>();
Collections.addAll(usedFields, stepMeta.getHeaderField());
Collections.addAll(usedFields, stepMeta.getArgumentField());
if (stepMeta.isUrlInField()) {
usedFields.add(stepMeta.getUrlField());
}
// check the param field is "used"
Iterable<StreamFieldNode> streamFieldNodesUses = node.getStreamFieldNodesUses();
assertEquals(usedFields.size(), getIterableSize(streamFieldNodesUses));
for (StreamFieldNode streamFieldNodesUse : streamFieldNodesUses) {
assertTrue(usedFields.contains(streamFieldNodesUse.getName()));
}
Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
assertEquals(getExpectedOutputFieldCount(stepMeta), getIterableSize(outputs));
}
use of org.pentaho.metaverse.frames.FramedMetaverseNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testTextFileOutputStepNode_FileFromStreamField.
@Test
public void testTextFileOutputStepNode_FileFromStreamField() throws Exception {
TextFileOutputStepNode textFileOutputStepNode = root.getTextFileOutputStepNode("textFileOutput", "Text file output - file from field");
TextFileOutputMeta meta = (TextFileOutputMeta) getStepMeta(textFileOutputStepNode);
TransMeta tm = meta.getParentStepMeta().getParentTransMeta();
RowMetaInterface incomingFields = tm.getPrevStepFields(meta.getParentStepMeta());
int outputFields = getExpectedOutputFieldCount(meta);
assertNotNull(textFileOutputStepNode);
// should write to one file
Iterable<FramedMetaverseNode> outputFiles = textFileOutputStepNode.getOutputFiles();
assertEquals(0, getIterableSize(outputFiles));
Iterable<StreamFieldNode> usedFields = textFileOutputStepNode.getStreamFieldNodesUses();
int usedFieldCount = getIterableSize(usedFields);
assertEquals(1, usedFieldCount);
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.FramedMetaverseNode 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.FramedMetaverseNode in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testEntity_Job.
@Test
public void testEntity_Job() throws Exception {
FramedMetaverseNode node = root.getEntity(DictionaryConst.NODE_TYPE_JOB);
assertEquals(DictionaryConst.NODE_TYPE_ENTITY, node.getType());
assertEquals(DictionaryConst.NODE_TYPE_JOB, node.getName());
assertEquals("Pentaho Data Integration", node.getDescription());
}
Aggregations