@Test public void simpleQuery() throws IOException { ServiceLocator locator = container; NextRepository repository = locator.resolve(NextRepository.class); repository.insert(new Next()); List<Next> search = repository.search(); Query<Next> stream = repository.query(); List<Next> list = stream.list(); Assert.assertEquals(search.size(), list.size()); }
@Test public void searchWithFilter() throws IOException { ServiceLocator locator = container; NextRepository repository = locator.resolve(NextRepository.class); String uri = repository.insert(new Next()); int id = Integer.parseInt(uri); List<Next> found = repository.search(next -> next.getID() == id); Assert.assertEquals(1, found.size()); Assert.assertEquals(id, found.get(0).getID()); }
@Test public void toStringAndValueOf() throws IOException { ServiceLocator locator = container; NextRepository repository = locator.resolve(NextRepository.class); String uri = repository.insert(new Next()); int id = Integer.parseInt(uri); List<Next> found = repository.search( it -> String.valueOf(it.getID()).equals(uri) && id == Integer.valueOf(it.getURI())); Assert.assertEquals(1, found.size()); Assert.assertEquals(id, found.get(0).getID()); }