@Test public void queryWithFilter() throws IOException { ServiceLocator locator = container; NextRepository repository = locator.resolve(NextRepository.class); String uri = repository.insert(new Next()); int id = Integer.parseInt(uri); Optional<Next> found = repository.query().filter(next -> next.getID() == id).findAny(); Assert.assertTrue(found.isPresent()); Assert.assertEquals(id, found.get().getID()); }
@Test public void queryWithNotFilter() throws IOException { ServiceLocator locator = container; NextRepository repository = locator.resolve(NextRepository.class); String uri = repository.insert(new Next()); int id = Integer.parseInt(uri); Specification<Next> filter = next -> next.getID() == id + 1; Optional<Next> found = repository.query().filter(filter).findAny(); Assert.assertFalse(found.isPresent()); // found = repository.query().filter(filter.negate()).findAny(); // Assert.assertTrue(found.isPresent()); }