Search in sources :

Example 1 with DatabaseLookupData

use of org.pentaho.di.trans.steps.databaselookup.DatabaseLookupData in project pentaho-kettle by pentaho.

the class ReadAllCacheTest method setUp.

@Before
public void setUp() {
    stepData = new DatabaseLookupData();
    stepData.conditions = new int[4];
    keysMeta = new RowMeta();
    keysMeta.addValueMeta(new ValueMetaInteger());
    keysMeta.addValueMeta(new ValueMetaString());
    keysMeta.addValueMeta(new ValueMetaDate());
    keysMeta.addValueMeta(new ValueMetaInteger());
    keys = new Object[][] { new Object[] { 0L, "0", new Date(0), null }, new Object[] { 0L, "0", new Date(50), null }, new Object[] { 2L, "2", new Date(200), null }, new Object[] { 1L, "1", new Date(100), null }, new Object[] { 1L, "1", new Date(150), null } };
    data = new Object[][] { new Object[] { 0 }, new Object[] { 1 }, new Object[] { 2 }, new Object[] { 3 }, new Object[] { 4 } };
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) DatabaseLookupData(org.pentaho.di.trans.steps.databaselookup.DatabaseLookupData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Before(org.junit.Before)

Example 2 with DatabaseLookupData

use of org.pentaho.di.trans.steps.databaselookup.DatabaseLookupData in project pentaho-kettle by pentaho.

the class ReadAllCacheTest method lookup_HandlesAbsenceOfLookupValue.

@Test
public void lookup_HandlesAbsenceOfLookupValue() throws Exception {
    stepData = new DatabaseLookupData();
    stepData.conditions = new int[] { DatabaseLookupMeta.CONDITION_IS_NOT_NULL };
    ReadAllCache.Builder builder = new ReadAllCache.Builder(stepData, 2);
    RowMeta keysMeta = new RowMeta();
    keysMeta.addValueMeta(new ValueMetaInteger());
    builder.setKeysMeta(keysMeta);
    builder.add(new Object[] { null }, new Object[] { "null" });
    builder.add(new Object[] { 1L }, new Object[] { "one" });
    ReadAllCache cache = builder.build();
    Object[] found = cache.getRowFromCache(new RowMeta(), new Object[0]);
    assertArrayEquals("(keys[1] == 1L) --> row 2", new Object[] { "one" }, found);
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) DatabaseLookupData(org.pentaho.di.trans.steps.databaselookup.DatabaseLookupData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) Test(org.junit.Test)

Aggregations

RowMeta (org.pentaho.di.core.row.RowMeta)2 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)2 DatabaseLookupData (org.pentaho.di.trans.steps.databaselookup.DatabaseLookupData)2 Date (java.util.Date)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1