Ejemplo n.º 1
0
 @Test
 public void List_Deep_Keys() {
   User u = where(user.firstName.eq("Jaakko")).singleResult(user.addresses.any().street);
   for (Address a : u.getAddresses()) {
     assertNotNull(a.street);
     assertNull(a.city);
   }
 }
Ejemplo n.º 2
0
 @Test
 public void List_Keys() {
   User u =
       where(user.firstName.eq("Jaakko")).list(user.firstName, user.mainAddress().street).get(0);
   assertEquals("Jaakko", u.getFirstName());
   assertNull(u.getLastName());
   assertEquals("Aakatu", u.getMainAddress().street);
   assertNull(u.getMainAddress().postCode);
 }
Ejemplo n.º 3
0
 @Test
 public void References() {
   for (User u : users) {
     if (u.getFriend() != null) {
       assertQuery(user.friend().eq(u.getFriend()), u);
       where(user.friend().ne(u.getFriend())).list();
     }
   }
 }
Ejemplo n.º 4
0
 private User addUser(
     String first, String last, int age, Address mainAddress, Address... addresses) {
   User user = new User(first, last, age, new Date());
   user.setGender(Gender.MALE);
   user.setMainAddress(mainAddress);
   for (Address address : addresses) {
     user.addAddress(address);
   }
   for (User u : users) {
     user.addFriend(u);
   }
   if (!users.isEmpty()) {
     user.setFriend(users.get(users.size() - 1));
   }
   ds.save(user);
   users.add(user);
   return user;
 }
Ejemplo n.º 5
0
 @Test
 public void SingleResult_Keys() {
   User u = where(user.firstName.eq("Jaakko")).singleResult(user.firstName);
   assertEquals("Jaakko", u.getFirstName());
   assertNull(u.getLastName());
 }
Ejemplo n.º 6
0
 @Test
 public void Find_By_Id() {
   assertNotNull(where(user.id.eq(u1.getId())).singleResult() != null);
 }
Ejemplo n.º 7
0
 @Test
 public void Exists() {
   assertTrue(where(user.firstName.eq("Jaakko")).exists());
   assertFalse(where(user.firstName.eq("JaakkoX")).exists());
   assertTrue(where(user.id.eq(u1.getId())).exists());
 }