@Test public void testReaderReturnsEmptyIteratorForNullValue() { Mockito.when(tabixReader.query("13:12-12")).thenReturn(null); Iterable<Entity> actual = tabixRepository.findAll(tabixRepository.query().eq(CHROM, "13").and().eq(POS, 12)); assertEquals(Collections.emptyList(), Lists.newArrayList(actual)); }
@Test public void testReaderFiltersRows() throws IOException { Mockito.when(tabixReader.query("13:12-12")).thenReturn(iterator); Mockito.when(iterator.next()) .thenReturn( "id1\t13\t11\tnope", "id2\t13\t12\tyup", "id3\t13\t12\tyup", "id3\t13\t13\tnope", null); Iterable<Entity> actual = tabixRepository.findAll(tabixRepository.query().eq(CHROM, "13").and().eq(POS, 12)); Entity e1 = new MapEntity(entityMetaData); e1.set("ID", "id2"); e1.set("#CHROM", "13"); e1.set("POS", 12l); e1.set("Description", "yup"); Entity e2 = new MapEntity(entityMetaData); e2.set("ID", "id3"); e2.set("#CHROM", "13"); e2.set("POS", 12l); e2.set("Description", "yup"); assertEquals(Lists.newArrayList(actual), Arrays.asList(e1, e2)); }