Search in sources :

Example 76 with ValueMetaInterface

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

the class ValueMetaBaseTest method testMetdataPreviewSqlTimestampToPentahoDate.

@Test
public void testMetdataPreviewSqlTimestampToPentahoDate() throws SQLException, KettleDatabaseException {
    doReturn(Types.TIMESTAMP).when(resultSet).getInt("DATA_TYPE");
    doReturn(mock(Object.class)).when(resultSet).getObject("DECIMAL_DIGITS");
    doReturn(19).when(resultSet).getInt("DECIMAL_DIGITS");
    doReturn(mock(OracleDatabaseMeta.class)).when(dbMetaMock).getDatabaseInterface();
    doReturn(true).when(dbMetaMock).supportsTimestampDataType();
    ValueMetaInterface valueMeta = valueMetaBase.getMetadataPreview(dbMetaMock, resultSet);
    assertTrue(valueMeta.isDate());
    assertEquals(-1, valueMeta.getPrecision());
    assertEquals(19, valueMeta.getLength());
}
Also used : OracleDatabaseMeta(org.pentaho.di.core.database.OracleDatabaseMeta) LoggingObject(org.pentaho.di.core.logging.LoggingObject) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 77 with ValueMetaInterface

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

the class ValueMetaBaseTest method testMetdataPreviewSqlBigIntToPentahoInteger.

@Test
public void testMetdataPreviewSqlBigIntToPentahoInteger() throws SQLException, KettleDatabaseException {
    doReturn(Types.BIGINT).when(resultSet).getInt("DATA_TYPE");
    ValueMetaInterface valueMeta = valueMetaBase.getMetadataPreview(dbMetaMock, resultSet);
    assertTrue(valueMeta.isInteger());
    assertEquals(0, valueMeta.getPrecision());
    assertEquals(15, valueMeta.getLength());
}
Also used : ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 78 with ValueMetaInterface

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

the class ValueMetaBaseTest method testMetdataPreviewSqlVarBinaryToPentahoBinary.

@Test
public void testMetdataPreviewSqlVarBinaryToPentahoBinary() throws SQLException, KettleDatabaseException {
    doReturn(Types.VARBINARY).when(resultSet).getInt("DATA_TYPE");
    doReturn(mock(PostgreSQLDatabaseMeta.class)).when(dbMetaMock).getDatabaseInterface();
    ValueMetaInterface valueMeta = valueMetaBase.getMetadataPreview(dbMetaMock, resultSet);
    assertTrue(valueMeta.isBinary());
}
Also used : PostgreSQLDatabaseMeta(org.pentaho.di.core.database.PostgreSQLDatabaseMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 79 with ValueMetaInterface

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

the class ValueMetaBaseTest method testMetdataPreviewSqlLongVarBinaryToPentahoBinary.

@Test
public void testMetdataPreviewSqlLongVarBinaryToPentahoBinary() throws SQLException, KettleDatabaseException {
    doReturn(Types.LONGVARBINARY).when(resultSet).getInt("DATA_TYPE");
    doReturn(mock(PostgreSQLDatabaseMeta.class)).when(dbMetaMock).getDatabaseInterface();
    ValueMetaInterface valueMeta = valueMetaBase.getMetadataPreview(dbMetaMock, resultSet);
    assertTrue(valueMeta.isBinary());
}
Also used : PostgreSQLDatabaseMeta(org.pentaho.di.core.database.PostgreSQLDatabaseMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 80 with ValueMetaInterface

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

the class ValueMetaBaseTest method testMetdataPreviewSqlNumericWithStrictBigNumberInterpretationUsingOracle.

@Test
public void testMetdataPreviewSqlNumericWithStrictBigNumberInterpretationUsingOracle() throws SQLException, KettleDatabaseException {
    doReturn(Types.NUMERIC).when(resultSet).getInt("DATA_TYPE");
    doReturn(38).when(resultSet).getInt("COLUMN_SIZE");
    doReturn(mock(Object.class)).when(resultSet).getObject("DECIMAL_DIGITS");
    doReturn(0).when(resultSet).getInt("DECIMAL_DIGITS");
    doReturn(mock(OracleDatabaseMeta.class)).when(dbMetaMock).getDatabaseInterface();
    when(((OracleDatabaseMeta) dbMetaMock.getDatabaseInterface()).strictBigNumberInterpretation()).thenReturn(true);
    ValueMetaInterface valueMeta = valueMetaBase.getMetadataPreview(dbMetaMock, resultSet);
    assertTrue(valueMeta.isBigNumber());
}
Also used : OracleDatabaseMeta(org.pentaho.di.core.database.OracleDatabaseMeta) LoggingObject(org.pentaho.di.core.logging.LoggingObject) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Aggregations

ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)908 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)345 KettleException (org.pentaho.di.core.exception.KettleException)269 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)243 RowMeta (org.pentaho.di.core.row.RowMeta)232 Test (org.junit.Test)212 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)146 KettleStepException (org.pentaho.di.core.exception.KettleStepException)120 ArrayList (java.util.ArrayList)111 TableItem (org.eclipse.swt.widgets.TableItem)78 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)76 KettleValueException (org.pentaho.di.core.exception.KettleValueException)58 FileObject (org.apache.commons.vfs2.FileObject)55 Date (java.util.Date)49 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)48 StepMeta (org.pentaho.di.trans.step.StepMeta)47 Database (org.pentaho.di.core.database.Database)46 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)46 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)44 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)43