@Test
public void testGroupMembershipMethod() {

    Schema schema = ZMSSchema.instance();
    Validator validator = new Validator(schema);
    GroupMembership ms = new GroupMembership().init();
    assertTrue(ms.getIsMember());
    assertTrue(ms.getActive());
    assertTrue(ms.getApproved());
    ms.setMemberName("test.member").setIsMember(false).setGroupName("group1")
            .setExpiration(Timestamp.fromMillis(100)).setAuditRef("audit-ref")
            .setActive(true).setApproved(false).setRequestPrincipal("user.admin")
            .setSystemDisabled(1);
    // init second time does not change state
    ms.init();
    assertFalse(ms.getIsMember());
    assertTrue(ms.getActive());
    assertFalse(ms.getApproved());
    Result result = validator.validate(ms, "GroupMembership");
    assertTrue(result.valid);
    assertEquals(ms.getMemberName(), "test.member");
    assertFalse(ms.getIsMember());
    assertEquals(ms.getGroupName(), "group1");
    assertEquals(ms.getExpiration(), Timestamp.fromMillis(100));
    assertTrue(ms.getActive());
    assertFalse(ms.getApproved());
    assertEquals(ms.getAuditRef(), "audit-ref");
    assertEquals(ms.getRequestPrincipal(), "user.admin");
    assertEquals(ms.getSystemDisabled(), Integer.valueOf(1));
    GroupMembership ms2 = new GroupMembership().setMemberName("test.member").setIsMember(false)
            .setExpiration(Timestamp.fromMillis(100)).setGroupName("group1")
            .setActive(true).setAuditRef("audit-ref").setApproved(false)
            .setRequestPrincipal("user.admin").setSystemDisabled(1);
    assertTrue(ms2.equals(ms));
    assertTrue(ms.equals(ms));
    ms2.setRequestPrincipal("user.test2");
    assertFalse(ms2.equals(ms));
    ms2.setRequestPrincipal(null);
    assertFalse(ms2.equals(ms));
    ms2.setRequestPrincipal("user.admin");
    assertTrue(ms2.equals(ms));
    ms2.setExpiration(null);
    assertFalse(ms2.equals(ms));
    ms2.setExpiration(Timestamp.fromMillis(100));
    assertTrue(ms2.equals(ms));
    ms2.setGroupName(null);
    assertFalse(ms2.equals(ms));
    ms2.setGroupName("group1");
    assertTrue(ms2.equals(ms));
    ms2.setIsMember(null);
    assertFalse(ms2.equals(ms));
    ms2.setIsMember(false);
    assertTrue(ms2.equals(ms));
    ms2.setMemberName(null);
    assertFalse(ms2.equals(ms));
    ms2.setMemberName("test.member");
    assertTrue(ms2.equals(ms));
    ms2.setAuditRef(null);
    assertFalse(ms2.equals(ms));
    ms2.setAuditRef("audit-ref");
    assertTrue(ms2.equals(ms));
    ms2.setActive(null);
    assertFalse(ms2.equals(ms));
    ms2.setActive(true);
    assertTrue(ms2.equals(ms));
    ms2.setApproved(null);
    assertFalse(ms2.equals(ms));
    ms2.setApproved(true);
    assertFalse(ms2.equals(ms));
    ms2.setApproved(false);
    assertTrue(ms2.equals(ms));
    ms2.setSystemDisabled(2);
    assertFalse(ms2.equals(ms));
    ms2.setSystemDisabled(null);
    assertFalse(ms2.equals(ms));
    ms2.setSystemDisabled(1);
    assertTrue(ms2.equals(ms));
    assertFalse(ms2.equals(null));
    assertFalse(ms.equals(new String()));
}