Package org.jugile.daims

Source Code of org.jugile.daims.PersonTest

package org.jugile.daims;

import org.jugile.daims.Bo;
import org.jugile.daims.DomainCore;
import org.jugile.daims.UnitOfWork;
import org.jugile.proto2.domain.Domain;
import org.jugile.proto2.domain.Family;
import org.jugile.proto2.domain.Person;
import org.jugile.util.JugileTestCase;
import org.jugile.util.Time;

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();
  }
 
  public void testAnno() {
    Person p = new Person();
    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);
   
  }
 
  public void testDomain() {
    Domain d = Domain.getDomain();
    Person p1 = d.createPerson(); // new instance, no origin
    p1.setName("Jukka");
    assertEquals("Jukka",p1.getName());
    d.rollback();
  }
 
 
}
TOP

Related Classes of org.jugile.daims.PersonTest

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.