@Test public void testExternalCommand() { String commandId = "command"; when(parsedCommand.getCommandId()).thenReturn(commandId); when(commandProvider.isCommandAvailable(commandId)).thenReturn(false); Command command = factory.create(parsedCommand); assertEquals(DelegateToServerCommand.class, command.getClass()); assertEquals(parsedCommand, ((DelegateToServerCommand) command).getParsedCommand()); }
@Test public void testInternalCommand() { class InnerCommand extends Command {} InnerCommand innerCommand = new InnerCommand(); String commandId = Commands.getId(innerCommand.getClass()); when(parsedCommand.getCommandId()).thenReturn(commandId); when(commandProvider.isCommandAvailable(commandId)).thenReturn(true); when(commandProvider.getCommandById(commandId)).thenReturn(innerCommand); Command command = factory.create(parsedCommand); assertEquals(innerCommand, command); }