示例#1
0
 // @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);
 }
示例#2
0
 @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);
 }
示例#3
0
 @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);
 }