TrustedUserPrincipal extends Principal { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final TrustedUserPrincipal other = (TrustedUserPrincipal) obj; if ((this.username == null) ? (other.username != null) : !this.username.equals(other.username)) { return false; } return true; } TrustedUserPrincipal(String username); String getUsername(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String getType(); @Override String getName(); @Override boolean hasFullAccess(); @Override boolean canAccess(Object target, SubResource subResource, Access access);  }
@Test public void equalsNull() { assertFalse(principal.equals(null)); }
@Test public void equalsOtherObject() { assertFalse(principal.equals(new Object())); }
@Test public void equalsAnotherConsumerPrincipal() { TrustedUserPrincipal tup = new TrustedUserPrincipal("admin"); assertTrue(principal.equals(tup)); }
@Test public void equalsDifferentConsumer() { TrustedUserPrincipal tup = new TrustedUserPrincipal("donald"); assertFalse(principal.equals(tup)); }