use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.
the class CheckSumTest method testHexOutput_sha256.
@Test
public void testHexOutput_sha256() throws Exception {
MockRowListener results = executeHexTest(4, false, "xyz", new ValueMetaString("test"), false);
assertEquals(1, results.getWritten().size());
assertEquals("3608bca1e44ea6c4d268eb6db02260269892c0b42b86bbf1e77a6fa16c3c9282", results.getWritten().get(0)[1]);
results = executeHexTest(4, false, 10.8, new ValueMetaNumber("test"), false);
assertEquals(1, results.getWritten().size());
assertEquals("b52b603f9ec86c382a8483cad4f788f2f927535a76ad1388caedcef5e3c3c813", results.getWritten().get(0)[1]);
results = executeHexTest(4, false, 10.82, new ValueMetaNumber("test"), false);
assertEquals(1, results.getWritten().size());
assertEquals("45cbb96ff9625490cd675a7a39fecad6c167c1ed9b8957f53224fcb3e4a1e4a1", results.getWritten().get(0)[1]);
byte[] input = IOUtils.toByteArray(getFile("/org/pentaho/di/trans/steps/loadfileinput/files/pentaho_splash.png").getContent().getInputStream());
results = executeHexTest(4, false, input, new ValueMetaBinary("test"), false);
assertEquals(1, results.getWritten().size());
assertEquals("6914d0cb9296d658569570c23924ea4822be73f0ee3bc46d11651fb4041a43e1", results.getWritten().get(0)[1]);
}
use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.
the class Formula2IT method testIsNonText_EmptyStringIsNull.
@Test
public void testIsNonText_EmptyStringIsNull() throws KettleException {
FieldAccessorUtl.ensureEmptyStringIsNotNull(false);
final String fIsText = "ISNONTEXT([" + KEY_ARG + "])";
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { "1" }, false);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { "a" }, false);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { null }, true);
// assertBooleanFormula( fIsText, buildRowMeta( new ValueMetaString( KEY_ARG ) ), new Object[] { "" }, true ); //
// TODO: Is it correct?
//
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { "" }, false);
// TODO: Is it correct?
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { " " }, false);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaNumber(KEY_ARG)), new Object[] { 1 }, true);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaNumber(KEY_ARG)), new Object[] { 0 }, true);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaNumber(KEY_ARG)), new Object[] { -1.0 }, true);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaNumber(KEY_ARG)), new Object[] { null }, true);
}
use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.
the class Formula2IT method testIsNonText_EmptyStringIsNotNull.
@Test
public void testIsNonText_EmptyStringIsNotNull() throws KettleException {
FieldAccessorUtl.ensureEmptyStringIsNotNull(true);
final String fIsText = "ISNONTEXT([" + KEY_ARG + "])";
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { "1" }, false);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { "a" }, false);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { null }, true);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { "" }, false);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaString(KEY_ARG)), new Object[] { " " }, false);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaNumber(KEY_ARG)), new Object[] { 1 }, true);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaNumber(KEY_ARG)), new Object[] { 0 }, true);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaNumber(KEY_ARG)), new Object[] { -1.0 }, true);
assertBooleanFormula(fIsText, buildRowMeta(new ValueMetaNumber(KEY_ARG)), new Object[] { null }, true);
}
use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.
the class FormulaIT method getTestRowMetaAndData.
List<RowMetaAndData> getTestRowMetaAndData() {
List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();
Object[] row = new Object[] { null };
RowMetaInterface rm = new RowMeta();
rm.addValueMeta(new ValueMetaNumber("n"));
list.add(new RowMetaAndData(rm, row));
return list;
}
use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-cassandra-plugin by pentaho.
the class DriverCQLRowHandlerTest method testQueryRows.
@Test
public void testQueryRows() throws Exception {
List<Object[]> rowList = new ArrayList<Object[]>();
rowList.add(new Object[] { 1L, "a", 0.2d });
rowList.add(new Object[] { 2L, "b", 42d });
DriverKeyspace keyspace = mock(DriverKeyspace.class);
Session session = mock(Session.class);
ResultSet rs = mock(ResultSet.class);
mockColumnDefinitions(rs, DataType.cint(), DataType.text(), DataType.cdouble());
when(session.execute(anyString())).thenReturn(rs);
Iterator<Object[]> it = rowList.iterator();
when(rs.isExhausted()).then(invoc -> {
return !it.hasNext();
});
when(rs.one()).then(invocation -> {
Object[] rowArr = it.next();
Row row = mock(Row.class);
when(row.getObject(anyInt())).then(invoc -> {
return rowArr[(int) invoc.getArguments()[0]];
});
when(row.getLong(0)).thenReturn((long) rowArr[0]);
when(row.getDouble(2)).thenReturn((double) rowArr[2]);
return row;
});
DriverCQLRowHandler rowHandler = new DriverCQLRowHandler(keyspace, session, true);
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("a"));
rowMeta.addValueMeta(new ValueMetaString("b"));
rowMeta.addValueMeta(new ValueMetaNumber("c"));
rowHandler.newRowQuery(mock(StepInterface.class), "tab", "select * from tab", null, null, mock(LogChannelInterface.class));
List<Object[]> resultRows = getNextOutputRows(rowHandler, rowMeta);
assertEquals(2, resultRows.size());
assertEquals(2L, resultRows.get(1)[0]);
}
Aggregations