UserPrincipal extends Principal { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final UserPrincipal other = (UserPrincipal) obj; if ((this.username == null) ? (other.username != null) : !this.username.equals(other.username)) { return false; } return true; } UserPrincipal(String username, Collection<Permission> permissions, boolean admin); String getUsername(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String getType(); @Override String getName(); @Override boolean hasFullAccess(); List<String> getOwnerIds(); List<String> getOwnerKeys(); List<Owner> getOwners(); @Override boolean canAccess(Object target, SubResource subResource, Access access);  }
@Test public void equalsNull() { assertFalse(user.equals(null)); }
@Test public void equalsOtherObject() { assertFalse(user.equals(new Object())); }
@Test public void equalsAnotherConsumerPrincipal() { UserPrincipal up = new UserPrincipal("icup", null, true); assertTrue(user.equals(up)); }
@Test public void equalsDifferentConsumer() { UserPrincipal up = new UserPrincipal("admin", null, true); assertFalse(user.equals(up)); }