Ejemplo n.º 1
0
  @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());
  }
Ejemplo n.º 2
0
  @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);
  }