@Test public void hashCodeTest() throws ComponentLookupException { Collaborator c = new DefaultCollaborator(COLLABORATOR, this.access, this.helper); AccessLevel otherAccess = mock(AccessLevel.class); Collaborator other = new DefaultCollaborator(COLLABORATOR, this.access, this.helper); Assert.assertEquals(c.hashCode(), other.hashCode()); Assert.assertFalse(c.equals(null)); other = new DefaultCollaborator(COLLABORATOR, otherAccess, this.helper); Assert.assertNotEquals(c.hashCode(), other.hashCode()); other = new DefaultCollaborator(new DocumentReference("xwiki", "XWiki", "padams"), this.access, this.helper); Assert.assertNotEquals(c.hashCode(), other.hashCode()); other = new DefaultCollaborator(new DocumentReference("xwiki", "XWiki", "padams"), otherAccess, this.helper); Assert.assertNotEquals(c.hashCode(), other.hashCode()); }
@Override public int hashCode() { return Objects.hash(this.user, this.access); }
DefaultCollaborator implements Collaborator { @Override public int hashCode() { return Objects.hash(this.user, this.access); } }
DefaultCollaborator implements Collaborator { @Override public int hashCode() { return Objects.hash(this.user, this.access); } DefaultCollaborator(EntityReference user, AccessLevel access, EntityAccessHelper helper); }
DefaultCollaborator implements Collaborator { @Override public int hashCode() { return Objects.hash(this.user, this.access); } DefaultCollaborator(EntityReference user, AccessLevel access, EntityAccessHelper helper); @Override String getType(); @Override boolean isUser(); @Override boolean isGroup(); @Override EntityReference getUser(); @Override String getUsername(); @Override AccessLevel getAccessLevel(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); }
DefaultCollaborator implements Collaborator { @Override public int hashCode() { return Objects.hash(this.user, this.access); } DefaultCollaborator(EntityReference user, AccessLevel access, EntityAccessHelper helper); @Override String getType(); @Override boolean isUser(); @Override boolean isGroup(); @Override EntityReference getUser(); @Override String getUsername(); @Override AccessLevel getAccessLevel(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }