use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class ExcelWriterStepTest method testInjection.
@Test
public void testInjection() {
ExcelWriterStepMeta meta = new ExcelWriterStepMeta();
try {
List<StepInjectionMetaEntry> entries = stepMeta.getStepMetaInjectionInterface().getStepInjectionMetadataEntries();
for (StepInjectionMetaEntry entry : entries) {
switch(entry.getValueType()) {
case ValueMetaInterface.TYPE_STRING:
entry.setValue("new_".concat(entry.getKey()));
break;
case ValueMetaInterface.TYPE_BOOLEAN:
entry.setValue(Boolean.TRUE);
break;
default:
break;
}
if (!entry.getDetails().isEmpty()) {
List<StepInjectionMetaEntry> childEntries = entry.getDetails().get(0).getDetails();
for (StepInjectionMetaEntry childEntry : childEntries) {
switch(childEntry.getValueType()) {
case ValueMetaInterface.TYPE_STRING:
childEntry.setValue("new_".concat(childEntry.getKey()));
break;
case ValueMetaInterface.TYPE_BOOLEAN:
childEntry.setValue(Boolean.TRUE);
break;
default:
break;
}
}
}
}
stepMeta.getStepMetaInjectionInterface().injectStepMetadataEntries(entries);
assertEquals("Cell comment not properly injected... ", "new_CELLCOMMENT", stepMeta.getOutputFields()[0].getCommentField());
assertEquals("Format not properly injected... ", "new_FORMAT", stepMeta.getOutputFields()[0].getFormat());
assertEquals("Hyperlink not properly injected... ", "new_HYPERLINKFIELD", stepMeta.getOutputFields()[0].getHyperlinkField());
assertEquals("Name not properly injected... ", "new_NAME", stepMeta.getOutputFields()[0].getName());
assertEquals("Style cell not properly injected... ", "new_STYLECELL", stepMeta.getOutputFields()[0].getStyleCell());
assertEquals("Title not properly injected... ", "new_FIELDTITLE", stepMeta.getOutputFields()[0].getTitle());
assertEquals("Title style cell not properly injected... ", "new_TITLESTYLE", stepMeta.getOutputFields()[0].getTitleStyleCell());
assertEquals("Type not properly injected... ", 0, stepMeta.getOutputFields()[0].getType());
assertEquals("Comment author not properly injected... ", "new_COMMENTAUTHOR", stepMeta.getOutputFields()[0].getCommentAuthorField());
} catch (KettleException e) {
fail(e.getMessage());
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class ExcelWriterStepTest method testTopLevelMetadataEntries.
@Test
public void testTopLevelMetadataEntries() {
try {
List<StepInjectionMetaEntry> entries = stepMeta.getStepMetaInjectionInterface().getStepInjectionMetadataEntries();
String masterKeys = "FIELDS";
for (StepInjectionMetaEntry entry : entries) {
String key = entry.getKey();
assertTrue(masterKeys.contains(key));
masterKeys = masterKeys.replace(key, "");
}
assertTrue(masterKeys.trim().length() == 0);
} catch (KettleException e) {
fail(e.getMessage());
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class ExcelWriterStepTest method testChildLevelMetadataEntries.
@Test
public void testChildLevelMetadataEntries() {
try {
List<StepInjectionMetaEntry> entries = stepMeta.getStepMetaInjectionInterface().getStepInjectionMetadataEntries();
String childKeys = "NAME TYPE FORMAT STYLECELL FIELDTITLE TITLESTYLE " + "FORMULA HYPERLINKFIELD CELLCOMMENT COMMENTAUTHOR";
StepInjectionMetaEntry mappingEntry = null;
for (StepInjectionMetaEntry entry : entries) {
String key = entry.getKey();
if (key.equals("FIELDS")) {
mappingEntry = entry;
break;
}
}
assertNotNull(mappingEntry);
List<StepInjectionMetaEntry> fieldAttributes = mappingEntry.getDetails().get(0).getDetails();
for (StepInjectionMetaEntry attribute : fieldAttributes) {
String key = attribute.getKey();
assertTrue(childKeys.contains(key));
childKeys = childKeys.replace(key, "");
}
assertTrue(childKeys.trim().length() == 0);
} catch (KettleException e) {
fail(e.getMessage());
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class TextFileInputMetaInjectionTest method extractingAll.
@Test
public void extractingAll() throws Exception {
TextFileInputMetaInjection injection = new TextFileInputMetaInjection(new TextFileInputMeta());
List<StepInjectionMetaEntry> metadata = injection.getStepInjectionMetadataEntries();
List<StepInjectionMetaEntry> extracted = injection.extractStepMetadataEntries();
assertEquals(metadata.size(), extracted.size());
for (StepInjectionMetaEntry metaEntry : metadata) {
assertNotNull(metaEntry.getKey(), StepInjectionUtil.findEntry(extracted, metaEntry.getKey()));
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class TextFileInputMetaInjectionTest method assertInjected.
private static void assertInjected(List<StepInjectionMetaEntry> fields, List<StepInjectionMetaEntry> toBeInjected) {
Map<String, StepInjectionMetaEntry> map = new HashMap<String, StepInjectionMetaEntry>(fields.size());
for (StepInjectionMetaEntry field : fields) {
map.put(field.getKey(), field);
}
for (StepInjectionMetaEntry entry : toBeInjected) {
StepInjectionMetaEntry field = map.get(entry.getKey());
assertNotNull(entry.getKey(), field);
Object value = field.getValue();
if (value == null) {
assertNull(entry.getKey(), entry.getValue());
} else {
assertEquals(entry.getKey(), entry.getValue(), value);
}
}
}
Aggregations