@Test public void equalsWithNullUserTest() throws ComponentLookupException { Collaborator c = new DefaultCollaborator(null, this.access, this.helper); Assert.assertTrue(c.equals(c)); Assert.assertFalse(c.equals(null)); Collaborator other = new DefaultCollaborator(null, this.access, this.helper); Assert.assertTrue(c.equals(other)); Assert.assertTrue(other.equals(c)); AccessLevel otherAccess = mock(AccessLevel.class); other = new DefaultCollaborator(null, otherAccess, this.helper); Assert.assertFalse(c.equals(other)); Assert.assertFalse(other.equals(c)); other = new DefaultCollaborator(new DocumentReference("xwiki", "XWiki", "padams"), this.access, this.helper); Assert.assertFalse(c.equals(other)); Assert.assertFalse(other.equals(c)); other = new DefaultCollaborator(new DocumentReference("xwiki", "XWiki", "padams"), otherAccess, this.helper); Assert.assertFalse(c.equals(other)); Assert.assertFalse(other.equals(c)); Assert.assertFalse(c.equals("other")); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } final Collaborator otherCollaborator = (Collaborator) other; return Objects.equals(this.user, otherCollaborator.getUser()) && Objects.equals(this.access, otherCollaborator.getAccessLevel()); }
DefaultCollaborator implements Collaborator { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } final Collaborator otherCollaborator = (Collaborator) other; return Objects.equals(this.user, otherCollaborator.getUser()) && Objects.equals(this.access, otherCollaborator.getAccessLevel()); } }
DefaultCollaborator implements Collaborator { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } final Collaborator otherCollaborator = (Collaborator) other; return Objects.equals(this.user, otherCollaborator.getUser()) && Objects.equals(this.access, otherCollaborator.getAccessLevel()); } DefaultCollaborator(EntityReference user, AccessLevel access, EntityAccessHelper helper); }
DefaultCollaborator implements Collaborator { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } final Collaborator otherCollaborator = (Collaborator) other; return Objects.equals(this.user, otherCollaborator.getUser()) && Objects.equals(this.access, otherCollaborator.getAccessLevel()); } 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 boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } final Collaborator otherCollaborator = (Collaborator) other; return Objects.equals(this.user, otherCollaborator.getUser()) && Objects.equals(this.access, otherCollaborator.getAccessLevel()); } 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();  }