use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class JsonOutputTest method createRowMetaInterface.
/**
* Creates a RowMetaInterface with a ValueMetaInterface with the name "filename".
*
* @return
*/
public RowMetaInterface createRowMetaInterface() {
RowMetaInterface rowMetaInterface = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMetaString("filename") };
for (int i = 0; i < valuesMeta.length; i++) {
rowMetaInterface.addValueMeta(valuesMeta[i]);
}
return rowMetaInterface;
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class MetaInjectMetaInjectionTest method test.
@Test
public void test() throws Exception {
check("TRANS_NAME", new StringGetter() {
public String get() {
return meta.getTransName();
}
});
check("FILE_NAME", new StringGetter() {
public String get() {
return meta.getFileName();
}
});
check("DIRECTORY_PATH", new StringGetter() {
public String get() {
return meta.getDirectoryPath();
}
});
check("SOURCE_STEP_NAME", new StringGetter() {
public String get() {
return meta.getSourceStepName();
}
});
check("TARGET_FILE", new StringGetter() {
public String get() {
return meta.getTargetFile();
}
});
check("NO_EXECUTION", new BooleanGetter() {
public boolean get() {
return meta.isNoExecution();
}
});
check("STREAMING_SOURCE_STEP", new StringGetter() {
public String get() {
return meta.getStreamSourceStepname();
}
});
check("STREAMING_TARGET_STEP", new StringGetter() {
public String get() {
return meta.getStreamTargetStepname();
}
});
check("SOURCE_OUTPUT_NAME", new StringGetter() {
public String get() {
return meta.getSourceOutputFields().get(0).getName();
}
});
String[] typeNames = ValueMetaBase.getAllTypes();
checkStringToInt("SOURCE_OUTPUT_TYPE", new IntGetter() {
public int get() {
return meta.getSourceOutputFields().get(0).getType();
}
}, typeNames, getTypeCodes(typeNames));
check("SOURCE_OUTPUT_LENGTH", new IntGetter() {
public int get() {
return meta.getSourceOutputFields().get(0).getLength();
}
});
check("SOURCE_OUTPUT_PRECISION", new IntGetter() {
public int get() {
return meta.getSourceOutputFields().get(0).getPrecision();
}
});
check("MAPPING_SOURCE_STEP", new StringGetter() {
public String get() {
return meta.getMetaInjectMapping().get(0).getSourceStep();
}
});
check("MAPPING_SOURCE_FIELD", new StringGetter() {
public String get() {
return meta.getMetaInjectMapping().get(0).getSourceField();
}
});
check("MAPPING_TARGET_STEP", new StringGetter() {
public String get() {
return meta.getMetaInjectMapping().get(0).getTargetStep();
}
});
check("MAPPING_TARGET_FIELD", new StringGetter() {
public String get() {
return meta.getMetaInjectMapping().get(0).getTargetField();
}
});
check("TRANS_SEPECIFICATION_METHOD", new EnumGetter() {
@Override
public Enum<?> get() {
return meta.getSpecificationMethod();
}
}, ObjectLocationSpecificationMethod.class);
ValueMetaInterface mftt = new ValueMetaString("f");
injector.setProperty(meta, "TRANS_OBJECT_ID", setValue(mftt, TEST_ID), "f");
assertEquals(TEST_ID, meta.getTransObjectId().getId());
skipPropertyTest("TRANS_OBJECT_ID");
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class MetaInjectTest method injectMetaFromMultipleInputSteps.
@Test
public void injectMetaFromMultipleInputSteps() throws KettleException {
Map<TargetStepAttribute, SourceStepField> targetSourceMapping = new LinkedHashMap<TargetStepAttribute, SourceStepField>();
targetSourceMapping.put(new TargetStepAttribute(INJECTOR_STEP_NAME, "DATA_TYPE", true), new SourceStepField("TYPE_INPUT", "col_type"));
targetSourceMapping.put(new TargetStepAttribute(INJECTOR_STEP_NAME, "NAME", true), new SourceStepField("NAME_INPUT", "col_name"));
meta.setTargetSourceMapping(targetSourceMapping);
doReturn(new String[] { "NAME_INPUT", "TYPE_INPUT" }).when(transMeta).getPrevStepNames(any(StepMeta.class));
RowSet nameInputRowSet = mock(RowSet.class);
RowMeta nameRowMeta = new RowMeta();
nameRowMeta.addValueMeta(new ValueMetaString("col_name"));
doReturn(nameRowMeta).when(nameInputRowSet).getRowMeta();
doReturn(nameInputRowSet).when(metaInject).findInputRowSet("NAME_INPUT");
RowSet typeInputRowSet = mock(RowSet.class);
RowMeta typeRowMeta = new RowMeta();
typeRowMeta.addValueMeta(new ValueMetaString("col_type"));
doReturn(typeRowMeta).when(typeInputRowSet).getRowMeta();
doReturn(typeInputRowSet).when(metaInject).findInputRowSet("TYPE_INPUT");
doReturn(new Object[] { "FIRST_NAME" }).doReturn(null).when(metaInject).getRowFrom(nameInputRowSet);
doReturn(new Object[] { "String" }).doReturn(null).when(metaInject).getRowFrom(typeInputRowSet);
List<StepInjectionMetaEntry> injectionMetaEntryList = new ArrayList<StepInjectionMetaEntry>();
StepInjectionMetaEntry fields = new StepInjectionMetaEntry("FIELDS", ValueMetaInterface.TYPE_NONE, "");
StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry("FIELD", ValueMetaInterface.TYPE_NONE, "");
fields.getDetails().add(fieldEntry);
StepInjectionMetaEntry nameEntry = new StepInjectionMetaEntry("NAME", ValueMetaInterface.TYPE_STRING, "");
fieldEntry.getDetails().add(nameEntry);
StepInjectionMetaEntry dataEntry = new StepInjectionMetaEntry("DATA_TYPE", ValueMetaInterface.TYPE_STRING, "");
fieldEntry.getDetails().add(dataEntry);
injectionMetaEntryList.add(fields);
doReturn(injectionMetaEntryList).when(metaInjectionInterface).getStepInjectionMetadataEntries();
meta.setNoExecution(true);
assertTrue(metaInject.init(meta, data));
metaInject.processRow(meta, data);
StepInjectionMetaEntry expectedNameEntry = new StepInjectionMetaEntry("NAME", "FIRST_NAME", ValueMetaInterface.TYPE_STRING, "");
StepInjectionMetaEntry expectedDataEntry = new StepInjectionMetaEntry("DATA_TYPE", "String", ValueMetaInterface.TYPE_STRING, "");
verify(metaInject, atLeastOnce()).setEntryValueIfFieldExists(refEq(expectedNameEntry), any(RowMetaAndData.class), any(SourceStepField.class));
verify(metaInject, atLeastOnce()).setEntryValueIfFieldExists(refEq(expectedDataEntry), any(RowMetaAndData.class), any(SourceStepField.class));
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class MetaInjectTest method setEntryValue_string.
@Test
public void setEntryValue_string() throws KettleValueException {
StepInjectionMetaEntry entry = mock(StepInjectionMetaEntry.class);
doReturn(ValueMetaInterface.TYPE_STRING).when(entry).getValueType();
RowMetaAndData row = createRowMetaAndData(new ValueMetaString(TEST_FIELD), TEST_VALUE);
SourceStepField sourceField = new SourceStepField(TEST_SOURCE_STEP_NAME, TEST_FIELD);
MetaInject.setEntryValue(entry, row, sourceField);
verify(entry).setValue(TEST_VALUE);
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class AccessOutputTest method getTestRowMetaAndData.
List<RowMetaAndData> getTestRowMetaAndData(String[] value) {
List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();
Object[] row = new Object[value.length];
RowMetaInterface rm = new RowMeta();
for (int i = 0; i < value.length; i++) {
rm.addValueMeta(new ValueMetaString(FIELD_NAME));
row[i] = value[i];
}
list.add(new RowMetaAndData(rm, row));
return list;
}
Aggregations