### Question:
WikiCommand extends AbstractCommand { @Override public Command targetedCommand( final Object target ) { if ( !( target instanceof String ) ) { throw new IllegalArgumentException( "Target must non-null and of type String." ); } return new WikiCommand( getRequestContext(), getURLPattern(), getContentTemplate(), (String)target, m_action ); } private  WikiCommand( final ContextEnum currentContext, final String target ); private  WikiCommand( final ContextEnum currentContext, final String target, final String action ); private  WikiCommand( final String requestContext,
                         final String urlPattern,
                         final String contentTemplate,
                         final String target,
                         final String action ); private  WikiCommand( final String requestContext, final String urlPattern, final String contentTemplate, final String target ); @Override Command targetedCommand( final Object target ); @Override String getName(); @Override Permission requiredPermission(); static final Command ADMIN; static final Command CREATE_GROUP; static final Command ERROR; static final Command FIND; static final Command INSTALL; static final Command LOGIN; static final Command LOGOUT; static final Command MESSAGE; static final Command PREFS; static final Command WORKFLOW; }### Answer:
@Test public void testTargetedCommand() { Command a = WikiCommand.CREATE_GROUP; Command b = a.targetedCommand( wiki ); Assertions.assertNotSame( a, b ); Assertions.assertEquals( a.getRequestContext(), b.getRequestContext() ); Assertions.assertEquals( a.getJSP(), b.getJSP() ); Assertions.assertEquals( a.getURLPattern(), b.getURLPattern() ); Assertions.assertEquals( a.getContentTemplate(), b.getContentTemplate() ); Assertions.assertNotNull( b.getTarget() ); Assertions.assertNotNull( b.requiredPermission() ); Assertions.assertEquals( new WikiPermission( wiki, "createGroups" ), b.requiredPermission() ); Assertions.assertEquals( wiki, b.getTarget() ); a = WikiCommand.ERROR; b = a.targetedCommand( wiki ); Assertions.assertNotSame( a, b ); Assertions.assertNotNull( b.getTarget() ); Assertions.assertNull( b.requiredPermission() ); Assertions.assertEquals( wiki, b.getTarget() ); a = WikiCommand.FIND; b = a.targetedCommand( wiki ); Assertions.assertNotSame( a, b ); Assertions.assertNotNull( b.getTarget() ); Assertions.assertNull( b.requiredPermission() ); Assertions.assertEquals( wiki, b.getTarget() ); a = WikiCommand.INSTALL; b = a.targetedCommand( wiki ); Assertions.assertNotSame( a, b ); Assertions.assertNotNull( b.getTarget() ); Assertions.assertNull( b.requiredPermission() ); Assertions.assertEquals( wiki, b.getTarget() ); a = WikiCommand.LOGIN; b = a.targetedCommand( wiki ); Assertions.assertNotSame( a, b ); Assertions.assertNotNull( b.getTarget() ); Assertions.assertNotNull( b.requiredPermission() ); Assertions.assertEquals( new WikiPermission( wiki, "login" ), b.requiredPermission() ); Assertions.assertEquals( wiki, b.getTarget() ); a = WikiCommand.LOGOUT; b = a.targetedCommand( wiki ); Assertions.assertNotSame( a, b ); Assertions.assertNotNull( b.getTarget() ); Assertions.assertNotNull( b.requiredPermission() ); Assertions.assertEquals( new WikiPermission( wiki, "login" ), b.requiredPermission() ); Assertions.assertEquals( wiki, b.getTarget() ); a = WikiCommand.PREFS; b = a.targetedCommand( wiki ); Assertions.assertNotSame( a, b ); Assertions.assertNotNull( b.getTarget() ); Assertions.assertNotNull( b.requiredPermission() ); Assertions.assertEquals( new WikiPermission( wiki, "editProfile" ), b.requiredPermission() ); Assertions.assertEquals( wiki, b.getTarget() ); }