/** * With minIds we can limit the number of elements returned. * * @throws IndexingException */ @Test public void minIdQuery() throws IndexingException { addElements(arrayBasedStorageLeaf, 100); IndexQuery indexQuery = mock(IndexQuery.class); when(indexQuery.getMinId()).thenReturn(51L); List<IStorageDescriptor> result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, hasSize(50)); for (IStorageDescriptor descriptor : result) { assertThat(descriptor.getChannelId(), is(LEAF_ID)); } }
/** * Exclude/include ID also can be define in query. * * @throws IndexingException */ @Test public void includeExcludeIdQuery() throws IndexingException { addElements(arrayBasedStorageLeaf, 100); StorageIndexQuery indexQuery = mock(StorageIndexQuery.class); List<Long> includeIds = new ArrayList<>(); List<Long> excludeIds = new ArrayList<>(); when(indexQuery.getIncludeIds()).thenReturn(includeIds); when(indexQuery.getExcludeIds()).thenReturn(excludeIds); includeIds.add(50L); List<IStorageDescriptor> result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, hasSize(1)); excludeIds.add(50L); result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, is(empty())); when(indexQuery.getIncludeIds()).thenReturn(null); result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, hasSize(99)); when(indexQuery.getMinId()).thenReturn(100L); result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, hasSize(1)); }