### Question:
WikiPermission extends Permission implements Serializable { public boolean implies( Permission permission ) { if ( !( permission instanceof WikiPermission ) ) { return false; } WikiPermission p = (WikiPermission) permission; boolean impliedWiki = PagePermission.isSubset( m_wiki, p.m_wiki ); int impliedMask = impliedMask( m_mask ); return impliedWiki && ( impliedMask & p.m_mask ) == p.m_mask; } 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 testImpliesPermission() { WikiPermission p1 = new WikiPermission("*", "createPages,createGroups,editProfile"); WikiPermission p2 = new WikiPermission("*", "createPages"); WikiPermission p3 = new WikiPermission("*", "createGroups"); WikiPermission p5 = new WikiPermission("*", "editPreferences"); WikiPermission p6 = new WikiPermission("*", "editProfile"); Assertions.assertTrue(p1.implies(p2)); Assertions.assertFalse(p2.implies(p1)); Assertions.assertTrue(p1.implies(p3)); Assertions.assertFalse(p3.implies(p1)); Assertions.assertTrue(p1.implies(p6)); Assertions.assertFalse(p6.implies(p1)); Assertions.assertTrue(p3.implies(p2)); Assertions.assertFalse(p2.implies(p3)); Assertions.assertFalse(p6.implies(p5)); Assertions.assertFalse(p6.implies(p3)); Assertions.assertFalse(p6.implies(p3)); Assertions.assertFalse(p6.implies(p1)); }
@Test public void testImpliesPermissionNS() { WikiPermission p1 = new WikiPermission("*", "createPages,createGroups,editProfile"); WikiPermission p2 = new WikiPermission("mywiki", "createPages"); WikiPermission p3 = new WikiPermission("mywiki", "createGroups"); WikiPermission p4 = new WikiPermission("urwiki", "editProfile"); WikiPermission p5 = new WikiPermission("*", "editPreferences"); Assertions.assertTrue(p1.implies(p2)); Assertions.assertFalse(p2.implies(p1)); Assertions.assertTrue(p1.implies(p3)); Assertions.assertFalse(p3.implies(p1)); Assertions.assertTrue(p1.implies(p4)); Assertions.assertFalse(p4.implies(p1)); Assertions.assertTrue(p3.implies(p2)); Assertions.assertFalse(p2.implies(p3)); Assertions.assertFalse(p5.implies(p4)); Assertions.assertFalse(p4.implies(p5)); }