public void testCleanUpConnectionsOnDelete() {
Domain.reset();
Domain d = Domain.getDomain();
Family f1 = d.createFamily().setName("f1");
Family f2 = d.createFamily().setName("f2");
Person p1 = d.createPerson().setName("p1");
Person p2 = d.createPerson().setName("p2");
f1.addPerson(p1);
f1.addPerson(p2);
assertEquals(2,f1.getPersons().size());
p1.delete();
assertEquals(1,f1.getPersons().size());
d.commit();
f1 = d.getFamily(f1.id());
assertEquals(1,f1.getPersons().size());
f2 = d.getFamily(f2.id());
p2 = d.getPerson(p2.id());
p2.addFriendFamily(f1);
p2.addFriendFamily(f2);
assertEquals(2,p2.getFriendFamilies().size());
f2.delete();
assertEquals(1,p2.getFriendFamilies().size());
d.commit();
p2 = d.getPerson(p2.id());
assertEquals(1,p2.getFriendFamilies().size());