// @Test public void numberFunctions() throws IOException { ServiceLocator locator = container; DataContext db = locator.resolve(DataContext.class); LocalDate ld = LocalDate.now(); Clicked cl = new Clicked().setDate(ld); db.submit(cl); Query<Clicked> query = db.query(Clicked.class); String uri = cl.getURI(); // TODO: produces incorrect queries boolean found1 = query.anyMatch( it -> Long.valueOf(3).equals(it.getBigint()) && it.getEn() == En.A || it.getURI().toUpperCase().equals(uri)); boolean found2 = query.anyMatch( it -> 3L >= it.getBigint() && it.getDate() == LocalDate.now() || Integer.valueOf(it.getURI()).equals(Integer.valueOf(uri))); boolean found3 = query.anyMatch( it -> Long.valueOf(3).equals(it.getBigint()) && it.getEn() == En.B || it.getURI().toUpperCase().equals(uri)); En b = En.B; boolean found4 = query.anyMatch(it -> it.getEn() == b || it.getURI().toUpperCase().equals(uri)); Assert.assertTrue(found1); Assert.assertTrue(found2); Assert.assertTrue(found3); Assert.assertTrue(found4); }
@Test public void staticMemberAccess() throws IOException { ServiceLocator locator = container; DataContext db = locator.resolve(DataContext.class); Query<Document> query = db.query(Document.class); boolean found = query.anyMatch(it -> it.equals(Document.MEANING_OF_LIFE())); Assert.assertFalse(found); }
@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 offsetDateTimeFunctions() throws IOException { ServiceLocator locator = container; DataContext db = locator.resolve(DataContext.class); Clicked cl = new Clicked(); db.submit(cl); Query<Clicked> query = db.query(Clicked.class); OffsetDateTime dt = cl.getQueuedAt(); boolean found = query.anyMatch( it -> it.getURI().equals(cl.getURI()) && it.getProcessedAt().compareTo(dt) == 0); boolean notFound = query.anyMatch( it -> it.getURI().equals(cl.getURI()) && it.getProcessedAt().compareTo(dt) != 0); Assert.assertTrue(found); Assert.assertFalse(notFound); }
@Test public void localDateFunctions() throws IOException { ServiceLocator locator = container; DataContext db = locator.resolve(DataContext.class); LocalDate ld = LocalDate.now(); Clicked cl = new Clicked().setDate(ld); db.submit(cl); Query<Clicked> query = db.query(Clicked.class); String uri = cl.getURI(); boolean found1 = query.anyMatch(it -> it.getURI().equals(uri) && ld.compareTo(it.getDate()) == 0); boolean found2 = query.anyMatch( it -> it.getURI().equals(uri) && ld.equals(it.getDate()) && ld.isEqual(it.getDate())); boolean notFound = query.anyMatch(it -> it.getURI().equals(uri) && ld.compareTo(it.getDate()) != 0); Assert.assertTrue(found1); Assert.assertTrue(found2); Assert.assertFalse(notFound); }