Ejemplo n.º 1
0
  /** Returns a new Role instance filled with random values. */
  public Role getRole() {
    Role role = new Role();

    // simple attributes follows
    role.setRoleName(ValueGenerator.getUniqueString(100));
    return role;
  }
 @Test
 public void isIdSetReturnsTrue() {
   Document model = new Document();
   model.setId(ValueGenerator.getUniqueString(32));
   assertNotNull(model.getId());
   assertTrue(model.isIdSet());
 }
  @Test
  public void equalsUsingPk() {
    Document model1 = new Document();
    Document model2 = new Document();

    String id = ValueGenerator.getUniqueString(32);
    model1.setId(id);
    model2.setId(id);

    model1.setDocumentContentType("a");
    model2.setDocumentContentType("a");

    model1.setDocumentSize(1);
    model2.setDocumentSize(1);

    model1.setDocumentFileName("a");
    model2.setDocumentFileName("a");

    model1.setDocumentBinary("d".getBytes());
    model2.setDocumentBinary("d".getBytes());

    model1.setVersion(1);
    model2.setVersion(1);
    assertTrue(model1.isIdSet());
    assertTrue(model2.isIdSet());
    assertTrue(model1.hashCode() == model2.hashCode());
    assertTrue(model1.equals(model2));
    assertTrue(model2.equals(model1));
  }
  @Test
  public void manyToOne_setAccount() {
    Document many = new Document();

    // init
    Account one = new Account();

    one.setId(ValueGenerator.getUniqueString(32));
    many.setAccount(one);

    // make sure it is propagated properly
    assertNotNull(many.getAccountId());
    assertEquals(one, many.getAccount());
    assertSame(many.getAccountId(), one.getId());
    // now set it to back to null
    many.setAccount(null);

    // make sure null is propagated properly
    assertNull(many.getAccount());

    // make sure it is propagated on fk column as well
    assertNull(many.getAccountId());
  }