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());
}
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;
}
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;
}
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;
}
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;
}
Aggregations