Exemplo n.º 1
0
 @Test
 public void testDeleteManyToMany() {
   final Person person = randomPerson();
   data.insert(person);
   final Collection<Group> groups = new ArrayList<>();
   data.runInTransaction(
       new Callable<Object>() {
         @Override
         public Object call() throws Exception {
           for (int i = 0; i < 10; i++) {
             Group group = new Group();
             group.setName("DeleteGroup" + i);
             data.insert(group);
             person.getGroups().add(group);
             groups.add(group);
           }
           data.update(person);
           return null;
         }
       });
   for (Group g : groups) {
     person.getGroups().remove(g);
   }
   data.update(person);
 }
Exemplo n.º 2
0
 @Test
 public void testInsertWithTransaction() {
   data.runInTransaction(
       new Callable<Object>() {
         @Override
         public Object call() throws Exception {
           for (int i = 0; i < 10; i++) {
             Person person = randomPerson();
             data.insert(person);
             assertTrue(person.getId() > 0);
           }
           return null;
         }
       });
 }
Exemplo n.º 3
0
 @Test
 public void testInsertWithTransactionCallable() {
   assertTrue(
       "success"
           .equals(
               data.runInTransaction(
                   new Callable<String>() {
                     @Override
                     public String call() {
                       for (int i = 0; i < 10; i++) {
                         Person person = randomPerson();
                         data.insert(person);
                         assertTrue(person.getId() > 0);
                       }
                       return "success";
                     }
                   })));
 }