package org.jugile.daims;
import org.jugile.proto2.domain.Domain;
import org.jugile.proto2.domain.Family;
import org.jugile.proto2.domain.Person;
import org.jugile.util.JugileTestCase;
public class DeleteCleanupN1Test extends JugileTestCase {
public void testRemoveFrom1NCollections() throws Exception {
DBTest.clearDatabase();
Domain.reset();
Domain d = Domain.getDomain();
Person p1 = d.createPerson().setName("p1");
Person p2 = d.createPerson().setName("p2");
Family f1 = d.createFamily().setName("f1");
f1.addPerson(p1);
f1.addPerson(p2);
d.commit();
f1 = d.getFamily(f1.id());
assertEquals(2, f1.getPersons().size());
//p1 = d.getPerson(p1.id());
//p2 = d.getPerson(p2.id());
d.dump("before delete");
for (Person p : f1.getPersons()) {
print("================================ DELETE: " + p);
p.delete();
}
d.dump("after delete");
assertEquals(0,f1.getPersons().size());
d.commit();
f1 = d.getFamily(f1.id());
assertEquals(0,f1.getPersons().size());
d.rollback();
}
}