Package domain

Examples of domain.Person


    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());
   
    d.rollback();
   
  }
View Full Code Here


  public void testDeleteNNEnd() {
    Domain.reset();
    Domain d = Domain.getDomain();
   
    Person p1 = d.createPerson().setName("p1");
    Family f1 = d.createFamily().setName("f1");
    p1.addFriendFamily(f1);
    assertEquals(1,p1.getFriendFamilies().size());
    assertEquals(1,f1.getFriendPersons().size());
    d.dump("1");
    d.commit();
    d.dump("2");
    p1 = d.getPerson(p1.id());
    f1 = d.getFamily(f1.id());
    assertEquals(1,p1.getFriendFamilies().size());
    assertEquals(1,f1.getFriendPersons().size());
    d.dump("3");
//    p1.delete();
//    assertEquals(0,f1.getFriendPersons().size());
    //f1.removeFriendPerson(p1);
   
    f1.delete();
    d.dump("deleted f1");
    assertEquals(0,p1.getFriendFamilies().size());

    d.rollback();
  }
View Full Code Here

    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.addFriendPerson(p1);
    f1.addFriendPerson(p2);

    d.commit();
   
    f1 = d.getFamily(f1.id());
    assertEquals(2,f1.getFriendPersons().size());
    p1 = d.getPerson(p1.id());
    assertEquals(1,p1.getFriendFamilies().size());
   
    f1.removeFriendPerson(p1); // family -> person
    f1 = d.getFamily(f1.id());
    assertEquals(1,f1.getFriendPersons().size());
    assertEquals(0,p1.getFriendFamilies().size());
    //d.dump("f1.removeFriendPerson(p1) done");

    d.commit();
   
    f1 = d.getFamily(f1.id());
    p2 = d.getPerson(p2.id());
    p2.removeFriendFamily(f1)// person -> family
    //d.dump("p2.removeFriendFamily(f1) done");

    assertEquals(0,p2.getFriendFamilies().size());
    assertEquals(0,f1.getFriendPersons().size());

    d.rollback();
  }
View Full Code Here

  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);
View Full Code Here

public class ExamplesTest extends JugileTestCase {
 
  public void testDemo1() {
   
    Domain d = Domain.getDomain();
    Person p1 = d.createPerson().setName("Bart Simpson").setAge(12).setTs(new Time("21.06.1971"));
    long id = p1.id();
    d.commit();
   
    p1 = d.getPerson(id);
    assertNotNull(p1);
    String name = p1.getName();
    assertEquals("Bart Simpson", name);
   
    d.rollback();
  }
View Full Code Here

public class PersonTest extends JugileTestCase {

  public void testSet() {
    Domain d = Domain.getDomain();
    Person p = (Person)Bo.createNew(Person.class);
    p.setName("Jukka");
    String name = p.getName();
    print("name: " + name);
   
    Family f = (Family)Bo.createNew(Family.class);
    f.setName("Rahkonen");
    p.setFamily(f);

    assertEquals("Rahkonen", p.getFamily().getName());
    d.rollback();
  }
View Full Code Here

    assertEquals("Rahkonen", p.getFamily().getName());
    d.rollback();
  }
 
  public void testAnno() {
    Person p = new Person();
    print("table: " + p.table());
    assertEquals("person_t",p.table());
  }
View Full Code Here

    print("table: " + p.table());
    assertEquals("person_t",p.table());
  }
 
  public void testCopy() {
    Person p = (Person)Bo.createNew(Person.class);
    p.setName("Jukka");
    p.setAge(40);
    p.setTs(new Time("21.06.1971"));
    assertEquals("Jukka",p.getName());
    assertEquals(40,p.getAge());
    assertEquals(new Time("21.06.1971"),p.getTs());

    UnitOfWork uow = DomainCore.getUnitOfWork();
    Family f = (Family)uow.createNewBo(Family.class);
    f.setName("Rahkonen");
    p.setFamily(f);
    assertEquals("Rahkonen",p.getFamily().getName());
   
    print("p: " +p);

    Person p2 = (Person)p.copy(p.bi());
    assertEquals("Jukka",p2.getName());
    assertEquals(40,p2.getAge());
    assertEquals(new Time("21.06.1971"),p2.getTs());
    assertEquals("Rahkonen",p2.getFamily().getName());

    assertNotSame(p,p2);
    assertEquals(p,p2); // TODO: should copy be equal to origin?
    assertFalse(p == p2);
    Person p3 = p;
    assertTrue(p == p3);
   
  }
View Full Code Here

   
  }
 
  public void testDomain() {
    Domain d = Domain.getDomain();
    Person p1 = d.createPerson(); // new instance, no origin
    p1.setName("Jukka");
    assertEquals("Jukka",p1.getName());
    d.rollback();
  }
View Full Code Here

    d.commit();
  }
 
  public void testCommitAndRollback() {
    Domain d = Domain.getDomain();
    Person p = d.createPerson();
    assertNotNull(p);
    d.commit();
   
    p = d.getPerson(p.id());
    d.commit();
    d.commit();
    d.rollback();
    p = d.getPerson(p.id());
    d.rollback();
    d.commit();
  }
View Full Code Here

TOP

Related Classes of domain.Person

Copyright © 2018 www.massapicom. 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.