Search in sources :

Example 1 with ValueMetaBinary

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

the class CheckSumTest method testHexOutput_md5_compatibilityMode.

@Test
public void testHexOutput_md5_compatibilityMode() throws Exception {
    MockRowListener results = executeHexTest(2, true, "xyz", new ValueMetaString("test"), false);
    assertEquals(1, results.getWritten().size());
    assertEquals("FD6FFD6F0911FD78FDFD1361FDFD705E", results.getWritten().get(0)[1]);
    results = executeHexTest(2, true, 10.8, new ValueMetaNumber("test"), false);
    assertEquals(1, results.getWritten().size());
    assertEquals("372DFDFD33FD1BFDFD6D225361FD7EFD", results.getWritten().get(0)[1]);
    results = executeHexTest(2, true, 10.82, new ValueMetaNumber("test"), false);
    assertEquals(1, results.getWritten().size());
    assertEquals("68FD42FD7143FD17FD17FDFD715957", results.getWritten().get(0)[1]);
    byte[] input = IOUtils.toByteArray(getFile("/org/pentaho/di/trans/steps/loadfileinput/files/pentaho_splash.png").getContent().getInputStream());
    results = executeHexTest(2, true, input, new ValueMetaBinary("test"), false);
    assertEquals(1, results.getWritten().size());
    assertEquals("FDFDFDFD051FFDFDFD50FD62FDFDFD13", results.getWritten().get(0)[1]);
}
Also used : ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) Test(org.junit.Test)

Example 2 with ValueMetaBinary

use of org.pentaho.di.core.row.value.ValueMetaBinary 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"));
}
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) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Test(org.junit.Test)

Example 3 with ValueMetaBinary

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

the class AzureSqlDataBaseMetaTest method testGetValueFromResultSet.

@Test
public void testGetValueFromResultSet() throws SQLException, KettleDatabaseException {
    ResultSet rs = mock(ResultSet.class);
    // Binary Data
    Mockito.when(rs.getString(1)).thenReturn("HODBACXXXXAAA");
    ValueMetaBinary tb = new ValueMetaBinary("HODBACXXXXAAA");
    assertEquals("HODBACXXXXAAA", dbMeta.getValueFromResultSet(rs, tb, 0));
    // Super class function calling
    Mockito.when(rs.getString(2)).thenReturn("AzureDB");
    ValueMetaString ts = new ValueMetaString("AzureDB");
    assertEquals("AzureDB", dbMeta.getValueFromResultSet(rs, ts, 1));
    // ResultSet was null
    Mockito.when(rs.wasNull()).thenReturn(true);
    assertNull(dbMeta.getValueFromResultSet(rs, tb, 2));
}
Also used : ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ResultSet(java.sql.ResultSet) Test(org.junit.Test)

Example 4 with ValueMetaBinary

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

the class LoadFileInputTest method testByteArray.

@Test
public void testByteArray() throws Exception {
    RowMetaInterface mockedRowMetaInterface = mock(RowMetaInterface.class);
    stepLoadFileInput.data.outputRowMeta = mockedRowMetaInterface;
    stepLoadFileInput.data.convertRowMeta = mockedRowMetaInterface;
    Mockito.doReturn(new ValueMetaString()).when(mockedRowMetaInterface).getValueMeta(anyInt());
    // byte array
    Mockito.doReturn(new ValueMetaBinary()).when(mockedRowMetaInterface).getValueMeta(anyInt());
    ((LoadFileInputMeta) runtimeSMI).setEncoding("UTF-8");
    stepInputFiles.addFile(getFile("pentaho_splash.png"));
    inputField = new LoadFileInputField();
    inputField.setType(ValueMetaInterface.TYPE_BINARY);
    ((LoadFileInputMeta) runtimeSMI).setInputFields(new LoadFileInputField[] { inputField });
    assertNotNull(stepLoadFileInput.getOneRow());
    assertArrayEquals(IOUtils.toByteArray(getFile("pentaho_splash.png").getContent().getInputStream()), stepLoadFileInput.data.filecontent);
}
Also used : ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Test(org.junit.Test)

Example 5 with ValueMetaBinary

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

the class FieldHelperTest method getGetSignature_Binary.

@Test
public void getGetSignature_Binary() {
    ValueMetaBinary v = new ValueMetaBinary("Data");
    String accessor = FieldHelper.getAccessor(true, "Data");
    assertEquals("byte[] Data = get(Fields.In, \"Data\").getBinary(r);", FieldHelper.getGetSignature(accessor, v));
    assertNotNull(getMethod(FieldHelper.class, "getBinary", Object[].class));
}
Also used : ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) Matchers.anyString(org.mockito.Matchers.anyString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)40 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)35 Test (org.junit.Test)31 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)22 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)18 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)15 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)14 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)14 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)13 ValueMetaInternetAddress (org.pentaho.di.core.row.value.ValueMetaInternetAddress)12 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)11 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)9 RowMeta (org.pentaho.di.core.row.RowMeta)7 ResultSet (java.sql.ResultSet)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 SQLException (java.sql.SQLException)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3 StepMeta (org.pentaho.di.trans.step.StepMeta)3 BatchUpdateException (java.sql.BatchUpdateException)2 Savepoint (java.sql.Savepoint)2