Search in sources :

Example 31 with ValueMetaBinary

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

the class DatabaseLookupUTest method testEqualsAndIsNullAreCached.

@Test
public void testEqualsAndIsNullAreCached() throws Exception {
    when(mockHelper.logChannelInterfaceFactory.create(any(), any(LoggingObjectInterface.class))).thenReturn(mockHelper.logChannelInterface);
    DatabaseLookup look = new MockDatabaseLookup(mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans);
    DatabaseLookupData lookData = new DatabaseLookupData();
    lookData.cache = DefaultCache.newCache(lookData, 0);
    lookData.lookupMeta = new RowMeta();
    MySQLDatabaseMeta mysql = new MySQLDatabaseMeta();
    mysql.setName("MySQL");
    DatabaseMeta dbMeta = new DatabaseMeta();
    dbMeta.setDatabaseInterface(mysql);
    DatabaseLookupMeta meta = new DatabaseLookupMeta();
    meta.setDatabaseMeta(dbMeta);
    meta.setTablename("VirtualTable");
    meta.setTableKeyField(new String[] { "ID1", "ID2" });
    meta.setKeyCondition(new String[] { "=", "IS NULL" });
    meta.setReturnValueNewName(new String[] { "val1", "val2" });
    meta.setReturnValueField(new String[] { BINARY_FIELD, BINARY_FIELD });
    meta.setReturnValueDefaultType(new int[] { ValueMetaInterface.TYPE_BINARY, ValueMetaInterface.TYPE_BINARY });
    meta.setStreamKeyField1(new String[0]);
    meta.setStreamKeyField2(new String[0]);
    meta.setReturnValueDefault(new String[] { "", "" });
    meta = spy(meta);
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            RowMetaInterface row = (RowMetaInterface) invocation.getArguments()[0];
            ValueMetaInterface v = new ValueMetaBinary(BINARY_FIELD);
            row.addValueMeta(v);
            return null;
        }
    }).when(meta).getFields(any(RowMetaInterface.class), anyString(), any(RowMetaInterface[].class), any(StepMeta.class), any(VariableSpace.class), any(Repository.class), any(IMetaStore.class));
    look.init(meta, lookData);
    // Test for fix on PDI-15202
    assertTrue(lookData.allEquals);
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) VariableSpace(org.pentaho.di.core.variables.VariableSpace) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) MySQLDatabaseMeta(org.pentaho.di.core.database.MySQLDatabaseMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) MySQLDatabaseMeta(org.pentaho.di.core.database.MySQLDatabaseMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Answer(org.mockito.stubbing.Answer) Repository(org.pentaho.di.repository.Repository) InvocationOnMock(org.mockito.invocation.InvocationOnMock) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) Test(org.junit.Test)

Aggregations

ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)31 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)29 Test (org.junit.Test)24 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)20 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)15 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)13 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)13 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)13 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)12 ValueMetaInternetAddress (org.pentaho.di.core.row.value.ValueMetaInternetAddress)11 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)10 RowMeta (org.pentaho.di.core.row.RowMeta)6 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)6 StepMeta (org.pentaho.di.trans.step.StepMeta)3 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2