@Test public void lookup_Finds_Only() throws Exception { ReadAllCache cache = buildCache( "=,<,=,IS NULL" ); Object[] found = cache.getRowFromCache( keysMeta.clone(), new Object[] { 1L, "2", new Date( 100 ), null } ); assertArrayEquals( "(keys[0] == 1) && (keys[1] < '2') && (keys[2] == 100) --> row 3", data[ 3 ], found ); }
@Test public void lookup_Finds_FirstMatching() throws Exception { ReadAllCache cache = buildCache( "=,IS NOT NULL,<=,IS NULL" ); Object[] found = cache.getRowFromCache( keysMeta.clone(), new Object[] { 1L, null, new Date( 1000000 ), null } ); assertArrayEquals( "(keys[0] == 1) && (keys[2] < 1000000) --> row 3", data[ 3 ], found ); }
@Test public void lookup_DoesNotFind_FilteredByIndex() throws Exception { ReadAllCache cache = buildCache( "=,IS NOT NULL,>=,IS NOT NULL" ); Object[] found = cache.getRowFromCache( keysMeta.clone(), new Object[] { 1L, null, new Date( 0 ), null } ); assertNull( "(keys[3] != NULL) --> none", found ); }
@Test public void hasDbConditionStopsSearching() throws Exception { stepData.hasDBCondition = true; assertNull( buildCache( "" ).getRowFromCache( keysMeta.clone(), keys[ 0 ] ) ); }
@Test( expected = UnsupportedOperationException.class ) public void storeRowInCache_ThrowsException() throws Exception { buildCache( "" ).storeRowInCache( new DatabaseLookupMeta(), keysMeta.clone(), keys[ 0 ], data[ 0 ] ); }
@Test public void lookup_DoesNotFind_WithBetweenOperator() throws Exception { RowMeta meta = keysMeta.clone(); meta.setValueMeta( 3, new ValueMetaDate() ); meta.addValueMeta( new ValueMetaInteger() ); ReadAllCache cache = buildCache( "<>,IS NOT NULL,BETWEEN,IS NULL" ); Object[] found = cache.getRowFromCache( meta, new Object[] { -1L, null, new Date( 1000 ), new Date( 2000 ), null } ); assertNull( "(1000 <= keys[2] <= 2000) --> none", found ); }
@Test public void lookup_Finds_WithBetweenOperator() throws Exception { RowMeta meta = keysMeta.clone(); meta.setValueMeta( 3, new ValueMetaDate() ); meta.addValueMeta( new ValueMetaInteger() ); ReadAllCache cache = buildCache( "<>,IS NOT NULL,BETWEEN,IS NULL" ); Object[] found = cache.getRowFromCache( meta, new Object[] { -1L, null, new Date( 140 ), new Date( 160 ), null } ); assertArrayEquals( "(140 <= keys[2] <= 160) --> row 4", data[ 4 ], found ); }
data.olapHelper.createRectangularOutput(); data.outputRowMeta = this.createRowMeta( data.olapHelper.getHeaderValues(), data.olapHelper.getCellValues() ).clone();