Search in sources :

Example 1 with Vertica5DatabaseMeta

use of org.pentaho.di.core.database.Vertica5DatabaseMeta in project pentaho-kettle by pentaho.

the class ValueMetaBaseTest method testVerticaTimeType.

@Test
public void testVerticaTimeType() throws Exception {
    // PDI-12244
    ResultSet resultSet = Mockito.mock(ResultSet.class);
    ResultSetMetaData metaData = Mockito.mock(ResultSetMetaData.class);
    ValueMetaInterface valueMetaInterface = Mockito.mock(ValueMetaInternetAddress.class);
    Mockito.when(resultSet.getMetaData()).thenReturn(metaData);
    Mockito.when(metaData.getColumnType(1)).thenReturn(Types.TIME);
    Mockito.when(resultSet.getTime(1)).thenReturn(new Time(0));
    Mockito.when(valueMetaInterface.getOriginalColumnType()).thenReturn(Types.TIME);
    Mockito.when(valueMetaInterface.getType()).thenReturn(ValueMetaInterface.TYPE_DATE);
    DatabaseInterface databaseInterface = new Vertica5DatabaseMeta();
    Object ret = databaseInterface.getValueFromResultSet(resultSet, valueMetaInterface, 0);
    assertEquals(new Time(0), ret);
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) Vertica5DatabaseMeta(org.pentaho.di.core.database.Vertica5DatabaseMeta) ResultSet(java.sql.ResultSet) Time(java.sql.Time) LoggingObject(org.pentaho.di.core.logging.LoggingObject) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 2 with Vertica5DatabaseMeta

use of org.pentaho.di.core.database.Vertica5DatabaseMeta in project pentaho-kettle by pentaho.

the class ValueMetaBaseTest method testGetBinaryWithLength_WhenBinarySqlTypesOfVertica.

@Test
public void testGetBinaryWithLength_WhenBinarySqlTypesOfVertica() throws Exception {
    final int binaryColumnIndex = 1;
    final int varbinaryColumnIndex = 2;
    final int expectedBinarylength = 1;
    final int expectedVarBinarylength = 80;
    ValueMetaBase obj = new ValueMetaBase();
    DatabaseMeta dbMeta = Mockito.spy(new DatabaseMeta());
    DatabaseInterface databaseInterface = new Vertica5DatabaseMeta();
    dbMeta.setDatabaseInterface(databaseInterface);
    ResultSet resultSet = Mockito.mock(ResultSet.class);
    ResultSetMetaData metaData = Mockito.mock(ResultSetMetaData.class);
    Mockito.when(resultSet.getMetaData()).thenReturn(metaData);
    Mockito.when(metaData.getColumnType(binaryColumnIndex)).thenReturn(Types.BINARY);
    Mockito.when(metaData.getPrecision(binaryColumnIndex)).thenReturn(expectedBinarylength);
    Mockito.when(metaData.getColumnDisplaySize(binaryColumnIndex)).thenReturn(expectedBinarylength * 2);
    Mockito.when(metaData.getColumnType(varbinaryColumnIndex)).thenReturn(Types.BINARY);
    Mockito.when(metaData.getPrecision(varbinaryColumnIndex)).thenReturn(expectedVarBinarylength);
    Mockito.when(metaData.getColumnDisplaySize(varbinaryColumnIndex)).thenReturn(expectedVarBinarylength * 2);
    // get value meta for binary type
    ValueMetaInterface binaryValueMeta = obj.getValueFromSQLType(dbMeta, TEST_NAME, metaData, binaryColumnIndex, false, false);
    assertNotNull(binaryValueMeta);
    assertTrue(TEST_NAME.equals(binaryValueMeta.getName()));
    assertTrue(ValueMetaInterface.TYPE_BINARY == binaryValueMeta.getType());
    assertTrue(expectedBinarylength == binaryValueMeta.getLength());
    Assert.assertFalse(binaryValueMeta.isLargeTextField());
    // get value meta for varbinary type
    ValueMetaInterface varbinaryValueMeta = obj.getValueFromSQLType(dbMeta, TEST_NAME, metaData, varbinaryColumnIndex, false, false);
    assertNotNull(varbinaryValueMeta);
    assertTrue(TEST_NAME.equals(varbinaryValueMeta.getName()));
    assertTrue(ValueMetaInterface.TYPE_BINARY == varbinaryValueMeta.getType());
    assertTrue(expectedVarBinarylength == varbinaryValueMeta.getLength());
    Assert.assertFalse(varbinaryValueMeta.isLargeTextField());
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) Vertica5DatabaseMeta(org.pentaho.di.core.database.Vertica5DatabaseMeta) ResultSet(java.sql.ResultSet) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) NetezzaDatabaseMeta(org.pentaho.di.core.database.NetezzaDatabaseMeta) MySQLDatabaseMeta(org.pentaho.di.core.database.MySQLDatabaseMeta) Vertica5DatabaseMeta(org.pentaho.di.core.database.Vertica5DatabaseMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Aggregations

ResultSet (java.sql.ResultSet)2 ResultSetMetaData (java.sql.ResultSetMetaData)2 Test (org.junit.Test)2 DatabaseInterface (org.pentaho.di.core.database.DatabaseInterface)2 Vertica5DatabaseMeta (org.pentaho.di.core.database.Vertica5DatabaseMeta)2 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)2 Time (java.sql.Time)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 MySQLDatabaseMeta (org.pentaho.di.core.database.MySQLDatabaseMeta)1 NetezzaDatabaseMeta (org.pentaho.di.core.database.NetezzaDatabaseMeta)1 LoggingObject (org.pentaho.di.core.logging.LoggingObject)1