### Question:
WikiPermission extends Permission implements Serializable { public boolean equals( Object obj ) { if ( !( obj instanceof WikiPermission ) ) { return false; } WikiPermission p = (WikiPermission) obj; return p.m_mask == m_mask && p.m_wiki != null && p.m_wiki.equals( m_wiki ); } WikiPermission( String wiki, String actions ); boolean equals( Object obj ); String getActions(); String getWiki(); int hashCode(); boolean implies( Permission permission ); PermissionCollection newPermissionCollection(); String toString(); static final String CREATE_GROUPS_ACTION; static final String CREATE_PAGES_ACTION; static final String LOGIN_ACTION; static final String EDIT_PREFERENCES_ACTION; static final String EDIT_PROFILE_ACTION; static final String WILDCARD; static final WikiPermission CREATE_GROUPS; static final WikiPermission CREATE_PAGES; static final WikiPermission LOGIN; static final WikiPermission EDIT_PREFERENCES; static final WikiPermission EDIT_PROFILE; }### Answer:
@Test public void testEqualsObject() { WikiPermission p1 = new WikiPermission("*", "createPages"); WikiPermission p2 = new WikiPermission("*", "createPages"); WikiPermission p3 = new WikiPermission("*", "createGroups"); Assertions.assertTrue(p1.equals(p2)); Assertions.assertTrue(p2.equals(p1)); Assertions.assertFalse(p1.equals(p3)); Assertions.assertFalse(p3.equals(p1)); WikiPermission p4 = new WikiPermission("*", "createPages,createGroups"); WikiPermission p5 = new WikiPermission("*", "createGroups,createPages"); Assertions.assertTrue(p4.equals(p5)); }
@Test public void testEqualsObjectNSi() { WikiPermission p1 = new WikiPermission("mywiki", "createPages"); WikiPermission p2 = new WikiPermission("*", "createPages"); WikiPermission p3 = new WikiPermission("mywiki", "createGroups"); Assertions.assertFalse(p1.equals(p2)); Assertions.assertFalse(p2.equals(p1)); Assertions.assertFalse(p1.equals(p3)); Assertions.assertFalse(p3.equals(p1)); WikiPermission p4 = new WikiPermission("mywiki", "createPages,createGroups"); WikiPermission p5 = new WikiPermission("*", "createGroups,createPages"); Assertions.assertFalse(p4.equals(p5)); }