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