Package org.jugile.proto2.domain

Examples of org.jugile.proto2.domain.Domain


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

public class BoCollectionTest extends JugileTestCase {
 
  public void testPaging() {
    Domain d = Domain.getDomain();
    PersonCollection pc = new PersonCollection();
    for (int i = 0; i < 20; i++) {
      Person p = d.createPerson();
      p.setName("p"+i);
      pc.add(p);
    }
    for (Person p : pc) {
      print("p: " + p);
    }
   
    pc.reset();
    List<Person> res = null;
    res = pc.page(0, 5, "id");
    assertEquals(true,pc.hasNextPage());
    assertEquals(false,pc.hasPrevPage());
    res = pc.page(1, 5, "id");
    assertEquals(true,pc.hasNextPage());
    assertEquals(true,pc.hasPrevPage());
    res = pc.page(4, 5, "id");
    assertEquals(false,pc.hasNextPage());
    assertEquals(true,pc.hasPrevPage());

    res = pc.page(10, 5, "id");
    assertEquals(false,pc.hasNextPage());
    assertEquals(false,pc.hasPrevPage());
   
    res = pc.page(5, 5, "id");
    assertEquals(false,pc.hasNextPage());
    assertEquals(true,pc.hasPrevPage());
   
  }
View Full Code Here

public class CollectionPropsTest extends JugileTestCase {
 
  public void testProps() {
    Domain d = Domain.getDomain();
    PersonCollection pc = new PersonCollection();
    pc.add(d.createPerson().setName("p1"), "p1");
    pc.add(d.createPerson().setName("p2"), "p2");
    pc.add(d.createPerson().setName("p3"), "p3");
    for (Person p : pc) {
      print(p.getName() + "=" + pc.getProp(p.id()));
    }
  }
View Full Code Here

TOP

Related Classes of org.jugile.proto2.domain.Domain

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.