Search in sources :

Example 11 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class SelectValuesTest method testPDI16368.

@Test
public void testPDI16368() throws Exception {
    // This tests that the fix for PDI-16388 doesn't get re-broken.
    // 
    SelectValuesHandler step2 = null;
    Object[] inputRow2 = null;
    RowMeta inputRowMeta = null;
    SelectValuesMeta stepMeta = null;
    SelectValuesData stepData = null;
    ValueMetaInterface vmi = null;
    // First, test current behavior (it's worked this way since 5.x or so)
    // 
    step2 = new SelectValuesHandler(helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans);
    step2 = spy(step2);
    // Starting with a BigDecimal (no places)
    inputRow2 = new Object[] { new BigDecimal("589") };
    doReturn(inputRow2).when(step2).getRow();
    doNothing().when(step2).putError(any(RowMetaInterface.class), any(Object[].class), anyLong(), anyString(), anyString(), anyString());
    inputRowMeta = new RowMeta();
    inputRowMeta.addValueMeta(new ValueMetaBigNumber(SELECTED_FIELD));
    step2.setInputRowMeta(inputRowMeta);
    stepMeta = new SelectValuesMeta();
    stepMeta.allocate(1, 0, 1);
    stepMeta.getSelectFields()[0] = new SelectField();
    stepMeta.getSelectFields()[0].setName(SELECTED_FIELD);
    stepMeta.getMeta()[0] = new SelectMetadataChange(stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_INTEGER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, // no specified conversion type so should have default conversion mask.
    null);
    stepData = new SelectValuesData();
    stepData.select = true;
    stepData.metadata = true;
    stepData.firstselect = true;
    stepData.firstmetadata = true;
    step2.processRow(stepMeta, stepData);
    vmi = step2.rowMeta.getValueMeta(0);
    assertEquals(ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask());
    step2 = new SelectValuesHandler(helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans);
    step2 = spy(step2);
    doReturn(inputRow2).when(step2).getRow();
    doNothing().when(step2).putError(any(RowMetaInterface.class), any(Object[].class), anyLong(), anyString(), anyString(), anyString());
    inputRowMeta = new RowMeta();
    inputRowMeta.addValueMeta(new ValueMetaBigNumber(SELECTED_FIELD));
    step2.setInputRowMeta(inputRowMeta);
    stepMeta = new SelectValuesMeta();
    stepMeta.allocate(1, 0, 1);
    stepMeta.getSelectFields()[0] = new SelectField();
    stepMeta.getSelectFields()[0].setName(SELECTED_FIELD);
    stepMeta.getMeta()[0] = new SelectMetadataChange(stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_NUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, // no specified conversion type so should have default conversion mask for Double.
    null);
    stepData = new SelectValuesData();
    stepData.select = true;
    stepData.metadata = true;
    stepData.firstselect = true;
    stepData.firstmetadata = true;
    step2.processRow(stepMeta, stepData);
    vmi = step2.rowMeta.getValueMeta(0);
    assertEquals(ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask());
    step2 = new SelectValuesHandler(helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans);
    step2 = spy(step2);
    // Starting with a Long
    inputRow2 = new Object[] { new Long("589") };
    doReturn(inputRow2).when(step2).getRow();
    doNothing().when(step2).putError(any(RowMetaInterface.class), any(Object[].class), anyLong(), anyString(), anyString(), anyString());
    inputRowMeta = new RowMeta();
    inputRowMeta.addValueMeta(new ValueMetaInteger(SELECTED_FIELD));
    step2.setInputRowMeta(inputRowMeta);
    stepMeta = new SelectValuesMeta();
    stepMeta.allocate(1, 0, 1);
    stepMeta.getSelectFields()[0] = new SelectField();
    stepMeta.getSelectFields()[0].setName(SELECTED_FIELD);
    // no specified conversion type so should have default conversion mask for BigNumber
    stepMeta.getMeta()[0] = new SelectMetadataChange(stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_BIGNUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null);
    stepData = new SelectValuesData();
    stepData.select = true;
    stepData.metadata = true;
    stepData.firstselect = true;
    stepData.firstmetadata = true;
    step2.processRow(stepMeta, stepData);
    vmi = step2.rowMeta.getValueMeta(0);
    assertEquals(ValueMetaBase.DEFAULT_INTEGER_FORMAT_MASK, vmi.getConversionMask());
    // Now, test that setting the variable results in getting the default conversion mask
    step2 = new SelectValuesHandler(helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans);
    step2.setVariable(Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y");
    step2 = spy(step2);
    // Starting with a BigDecimal (no places)
    inputRow2 = new Object[] { new BigDecimal("589") };
    doReturn(inputRow2).when(step2).getRow();
    doNothing().when(step2).putError(any(RowMetaInterface.class), any(Object[].class), anyLong(), anyString(), anyString(), anyString());
    inputRowMeta = new RowMeta();
    inputRowMeta.addValueMeta(new ValueMetaBigNumber(SELECTED_FIELD));
    step2.setInputRowMeta(inputRowMeta);
    stepMeta = new SelectValuesMeta();
    stepMeta.allocate(1, 0, 1);
    stepMeta.getSelectFields()[0] = new SelectField();
    stepMeta.getSelectFields()[0].setName(SELECTED_FIELD);
    stepMeta.getMeta()[0] = new SelectMetadataChange(stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_INTEGER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, // no specified conversion type so should have default conversion mask.
    null);
    stepData = new SelectValuesData();
    stepData.select = true;
    stepData.metadata = true;
    stepData.firstselect = true;
    stepData.firstmetadata = true;
    step2.processRow(stepMeta, stepData);
    vmi = step2.rowMeta.getValueMeta(0);
    assertEquals(ValueMetaBase.DEFAULT_INTEGER_FORMAT_MASK, vmi.getConversionMask());
    step2 = new SelectValuesHandler(helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans);
    step2.setVariable(Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y");
    step2 = spy(step2);
    doReturn(inputRow2).when(step2).getRow();
    doNothing().when(step2).putError(any(RowMetaInterface.class), any(Object[].class), anyLong(), anyString(), anyString(), anyString());
    inputRowMeta = new RowMeta();
    inputRowMeta.addValueMeta(new ValueMetaBigNumber(SELECTED_FIELD));
    step2.setInputRowMeta(inputRowMeta);
    stepMeta = new SelectValuesMeta();
    stepMeta.allocate(1, 0, 1);
    stepMeta.getSelectFields()[0] = new SelectField();
    stepMeta.getSelectFields()[0].setName(SELECTED_FIELD);
    stepMeta.getMeta()[0] = new SelectMetadataChange(stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_NUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, // no specified conversion type so should have default conversion mask for Double.
    null);
    stepData = new SelectValuesData();
    stepData.select = true;
    stepData.metadata = true;
    stepData.firstselect = true;
    stepData.firstmetadata = true;
    step2.processRow(stepMeta, stepData);
    vmi = step2.rowMeta.getValueMeta(0);
    assertEquals(ValueMetaBase.DEFAULT_NUMBER_FORMAT_MASK, vmi.getConversionMask());
    step2 = new SelectValuesHandler(helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans);
    step2.setVariable(Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y");
    step2 = spy(step2);
    // Starting with a Long
    inputRow2 = new Object[] { new Long("589") };
    doReturn(inputRow2).when(step2).getRow();
    doNothing().when(step2).putError(any(RowMetaInterface.class), any(Object[].class), anyLong(), anyString(), anyString(), anyString());
    inputRowMeta = new RowMeta();
    inputRowMeta.addValueMeta(new ValueMetaInteger(SELECTED_FIELD));
    step2.setInputRowMeta(inputRowMeta);
    stepMeta = new SelectValuesMeta();
    stepMeta.allocate(1, 0, 1);
    stepMeta.getSelectFields()[0] = new SelectField();
    stepMeta.getSelectFields()[0].setName(SELECTED_FIELD);
    // no specified conversion type so should have default conversion mask for BigNumber
    stepMeta.getMeta()[0] = new SelectMetadataChange(stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_BIGNUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null);
    stepData = new SelectValuesData();
    stepData.select = true;
    stepData.metadata = true;
    stepData.firstselect = true;
    stepData.firstmetadata = true;
    step2.processRow(stepMeta, stepData);
    vmi = step2.rowMeta.getValueMeta(0);
    assertEquals(ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask());
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) SelectField(org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta.SelectField) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) BigDecimal(java.math.BigDecimal) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) Matchers.anyLong(org.mockito.Matchers.anyLong) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) Test(org.junit.Test)

Example 12 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class MemoryGroupByMetaTest method getInputRowMeta.

private RowMetaInterface getInputRowMeta() {
    RowMetaInterface rm = new RowMeta();
    rm.addValueMeta(new ValueMetaString("myGroupField2"));
    rm.addValueMeta(new ValueMetaString("myGroupField1"));
    rm.addValueMeta(new ValueMetaString("myString"));
    rm.addValueMeta(new ValueMetaInteger("myInteger"));
    rm.addValueMeta(new ValueMetaNumber("myNumber"));
    rm.addValueMeta(new ValueMetaBigNumber("myBigNumber"));
    rm.addValueMeta(new ValueMetaBinary("myBinary"));
    rm.addValueMeta(new ValueMetaBoolean("myBoolean"));
    rm.addValueMeta(new ValueMetaDate("myDate"));
    rm.addValueMeta(new ValueMetaTimestamp("myTimestamp"));
    rm.addValueMeta(new ValueMetaInternetAddress("myInternetAddress"));
    return rm;
}
Also used : ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Example 13 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class InjectorIT method createRowMetaInterface.

public RowMetaInterface createRowMetaInterface() {
    RowMetaInterface rm = new RowMeta();
    ValueMetaInterface[] valuesMeta = { new ValueMetaString("field1"), new ValueMetaInteger("field2"), new ValueMetaNumber("field3"), new ValueMetaDate("field4"), new ValueMetaBoolean("field5"), new ValueMetaBigNumber("field6"), new ValueMetaBigNumber("field7") };
    for (int i = 0; i < valuesMeta.length; i++) {
        rm.addValueMeta(valuesMeta[i]);
    }
    return rm;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 14 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class MemoryGroupByIntIT method getTestRowMeta.

RowMetaInterface getTestRowMeta() {
    RowMetaInterface rm = new RowMeta();
    rm.addValueMeta(new ValueMetaString(KEY1));
    rm.addValueMeta(new ValueMetaInteger(KEY2));
    rm.addValueMeta(new ValueMetaNumber(KEY3));
    rm.addValueMeta(new ValueMetaBigNumber(KEY4));
    return rm;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger)

Example 15 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class DetectLastRowStepIT method createRowMetaInterface.

public RowMetaInterface createRowMetaInterface() {
    RowMetaInterface rm = new RowMeta();
    ValueMetaInterface[] valuesMeta = { new ValueMetaString("field1"), new ValueMetaInteger("field2"), new ValueMetaNumber("field3"), new ValueMetaBoolean("field5"), new ValueMetaBigNumber("field6") };
    for (int i = 0; i < valuesMeta.length; i++) {
        rm.addValueMeta(valuesMeta[i]);
    }
    return rm;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)34 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)31 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)30 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)28 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)25 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)23 RowMeta (org.pentaho.di.core.row.RowMeta)21 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)18 Test (org.junit.Test)17 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)15 ValueMetaInternetAddress (org.pentaho.di.core.row.value.ValueMetaInternetAddress)14 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)13 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)13 BigDecimal (java.math.BigDecimal)6 ArrayList (java.util.ArrayList)4 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)4 KettleException (org.pentaho.di.core.exception.KettleException)4 SQLException (java.sql.SQLException)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 BatchUpdateException (java.sql.BatchUpdateException)2