Package org.jugile.daims

Source Code of org.jugile.daims.DeleteCleanupN1Test

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();
   
  }
 
}
TOP

Related Classes of org.jugile.daims.DeleteCleanupN1Test

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.