Search in sources :

Example 91 with ValueMetaString

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;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 92 with ValueMetaString

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");
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) BaseMetadataInjectionTest(org.pentaho.di.core.injection.BaseMetadataInjectionTest) Test(org.junit.Test)

Example 93 with ValueMetaString

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));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) RowSet(org.pentaho.di.core.RowSet) ArrayList(java.util.ArrayList) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) LinkedHashMap(java.util.LinkedHashMap) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 94 with ValueMetaString

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);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 95 with ValueMetaString

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;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Aggregations

ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)447 RowMeta (org.pentaho.di.core.row.RowMeta)219 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)181 Test (org.junit.Test)179 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)176 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)141 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)86 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)67 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)66 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)57 KettleException (org.pentaho.di.core.exception.KettleException)40 ArrayList (java.util.ArrayList)33 LongObjectId (org.pentaho.di.repository.LongObjectId)29 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)27 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)26 ObjectId (org.pentaho.di.repository.ObjectId)26 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)21 RowSet (org.pentaho.di.core.RowSet)18 Date (java.util.Date)17 ValueMetaBase (org.pentaho.di.core.row.value.ValueMetaBase)16