示例#1
0
  @Test
  public void testSingleNamedMappedAttribute() {
    Employee employee = new Employee();

    employee.setFirstName("John");
    employee.setLastName("Paul");
    employee.setInternalId("33221221");

    getEntityManager().persist(employee);

    EmployeeUser user = new EmployeeUser("john");

    user.setPerson(employee);

    Email email = new Email();

    email.setAddress("*****@*****.**");
    email.setPrimaryEmail(true);

    user.setEmail(email);

    getIdentityManager().add(user);

    this.getEntityManager().getTransaction().commit();

    List<EmployeeUser> result =
        getIdentityManager().createIdentityQuery(EmployeeUser.class).getResultList();

    assertEquals(1, result.size());

    EmployeeUser storedUser = result.get(0);

    assertNotNull(storedUser.getEmail());
    assertEquals(user.getEmail(), storedUser.getEmail());
  }
示例#2
0
  @Test
  public void testSingleAttributeValue() {
    Employee employee = new Employee();

    employee.setFirstName("John");
    employee.setLastName("Paul");
    employee.setInternalId("33221221");

    getEntityManager().persist(employee);

    EmployeeUser user = new EmployeeUser("john");

    user.setPerson(employee);

    getIdentityManager().add(user);

    List<EmployeeUser> result =
        getIdentityManager().createIdentityQuery(EmployeeUser.class).getResultList();

    assertEquals(1, result.size());

    EmployeeUser storedUser = result.get(0);

    assertNotNull(storedUser.getPerson());
    assertEquals(user.getPerson().getClass(), storedUser.getPerson().getClass());
    assertEquals(user.getPerson(), storedUser.getPerson());
  }