use of org.pentaho.di.core.row.value.ValueMetaInteger 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.ValueMetaInteger in project pentaho-kettle by pentaho.
the class RowSetTest method createRowMetaInterface.
public RowMetaInterface createRowMetaInterface() {
RowMetaInterface rm = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("ROWNR") };
for (int i = 0; i < valuesMeta.length; i++) {
rm.addValueMeta(valuesMeta[i]);
}
return rm;
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class ConditionTest method testNullLessThanNumberEvaluatesAsFalse.
@Test
public void testNullLessThanNumberEvaluatesAsFalse() throws Exception {
RowMetaInterface rowMeta1 = new RowMeta();
rowMeta1.addValueMeta(new ValueMetaInteger("name1"));
String left = "name1";
ValueMetaAndData right_exact = new ValueMetaAndData(new ValueMetaInteger("name1"), new Long(-10));
Condition condition = new Condition(left, Condition.FUNC_SMALLER, null, right_exact);
assertFalse(condition.evaluate(rowMeta1, new Object[] { null, "test" }));
condition = new Condition(left, Condition.FUNC_SMALLER_EQUAL, null, right_exact);
assertFalse(condition.evaluate(rowMeta1, new Object[] { null, "test" }));
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class RowMetaAndDataTest method prepare.
@Before
public void prepare() throws Exception {
rowsMeta = new RowMeta();
ValueMetaInterface valueMetaString = new ValueMetaString("str");
rowsMeta.addValueMeta(valueMetaString);
ValueMetaInterface valueMetaBoolean = new ValueMetaBoolean("bool");
rowsMeta.addValueMeta(valueMetaBoolean);
ValueMetaInterface valueMetaInteger = new ValueMetaInteger("int");
rowsMeta.addValueMeta(valueMetaInteger);
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class RowMetaAndDataTest method testEmptyValues.
@Test
public void testEmptyValues() throws Exception {
RowMeta rowsMetaEmpty = new RowMeta();
rowsMetaEmpty.addValueMeta(new ValueMetaString("str"));
rowsMetaEmpty.addValueMeta(new ValueMetaBoolean("bool"));
rowsMetaEmpty.addValueMeta(new ValueMetaInteger("int"));
rowsMetaEmpty.addValueMeta(new ValueMetaNumber("num"));
rowsMetaEmpty.addValueMeta(new ValueMetaBigNumber("bignum"));
rowsMetaEmpty.addValueMeta(new ValueMetaBinary("bin"));
rowsMetaEmpty.addValueMeta(new ValueMetaDate("date"));
rowsMetaEmpty.addValueMeta(new ValueMetaTimestamp("timestamp"));
rowsMetaEmpty.addValueMeta(new ValueMetaInternetAddress("inet"));
row = new RowMetaAndData(rowsMetaEmpty, null, null, null, null, null, null, null, null, null);
assertTrue(row.isEmptyValue("str"));
assertTrue(row.isEmptyValue("bool"));
assertTrue(row.isEmptyValue("int"));
assertTrue(row.isEmptyValue("num"));
assertTrue(row.isEmptyValue("bignum"));
assertTrue(row.isEmptyValue("bin"));
assertTrue(row.isEmptyValue("date"));
assertTrue(row.isEmptyValue("timestamp"));
assertTrue(row.isEmptyValue("inet"));
}
Aggregations