@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); }
@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; } }); }
@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"; } }))); }