示例#1
0
 @Test
 public void uuidFunctions() throws IOException {
   ServiceLocator locator = container;
   CompositeRepository repository = locator.resolve(CompositeRepository.class);
   UUID id = UUID.randomUUID();
   String uri = repository.insert(new Composite().setId(id));
   Composite found =
       repository.query().filter(it -> it.getId().toString().equals(uri)).findAny().get();
   Assert.assertEquals(id, found.getId());
   found =
       repository.query().filter(it -> UUID.fromString(it.getURI()).equals(id)).findAny().get();
   Assert.assertEquals(id, found.getId());
 }
示例#2
0
 @Test
 public void substringMethods() throws IOException {
   ServiceLocator locator = container;
   CompositeRepository repository = locator.resolve(CompositeRepository.class);
   UUID id = UUID.randomUUID();
   repository.insert(
       new Composite().setId(id).setSimple(new Simple().setText("xxx" + id + "yyy")));
   List<Composite> found =
       repository
           .query()
           .filter(it -> it.getId().equals(id))
           .filter(it -> it.getSimple().getText().substring(3).equals(id.toString() + "yyy"))
           .filter(it -> it.getSimple().getText().substring(0, 3).equals("xxx"))
           .list();
   Assert.assertEquals(1, found.size());
   Assert.assertEquals(id, found.get(0).getId());
 }
示例#3
0
 @Test
 public void sendDomainObjectAsArgument() throws IOException {
   ServiceLocator locator = container;
   CompositeRepository repository = locator.resolve(CompositeRepository.class);
   UUID id = UUID.randomUUID();
   Random rnd = new Random();
   int next = rnd.nextInt(100000);
   repository.insert(
       new Composite().setId(id).setSimple(new Simple().setEn(En.A).setNumber(next)));
   Simple simple = new Simple().setEn(En.A).setNumber(next);
   Composite found =
       repository
           .query()
           .filter(it -> it.getSimple().getNumber() == simple.getNumber())
           .sortedBy(it -> it.getId())
           .findFirst()
           .get();
   Assert.assertEquals(id, found.getId());
 }