Exemplo n.º 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);
 }
Exemplo n.º 2
0
 @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);
 }
Exemplo n.º 3
0
 @Test
 public void floatType() throws IOException {
   ServiceLocator locator = container;
   DataContext db = locator.resolve(DataContext.class);
   boolean notFound =
       db.query(Composite.class).anyMatch(it -> (float) it.getSimple().getNumber() == 4.2f);
   Assert.assertFalse(notFound);
 }
Exemplo n.º 4
0
 @Test
 public void willRecognizeSpecificationOnSql() throws IOException {
   ServiceLocator locator = container;
   DataContext db = locator.resolve(DataContext.class);
   LocalDate ld = LocalDate.now();
   Clicked cl = new Clicked().setDate(ld);
   db.submit(cl);
   long count = db.query(ClickedList.class).filter(new ClickedList.FindAt(ld)).count();
   Assert.assertTrue(count > 0);
 }
Exemplo n.º 5
0
 // @Test
 public void nestedSubqueryWithStream() throws IOException {
   ServiceLocator locator = container;
   DataContext db = locator.resolve(DataContext.class);
   // TODO: does not work yet
   boolean notFound =
       db.query(Composite.class)
           .anyMatch(
               it ->
                   it.getEntities()
                       .stream()
                       .anyMatch(e -> e.getDetail1().stream().anyMatch(d -> d.getFf() == 4.2f)));
   Assert.assertFalse(notFound);
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
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);
 }