@Theory
  public void tokensPreservesOrderInWhichArgsAreGiven(String[] xs, String[] ys, String[] zs) {
    String progName = "prog";
    Stream<CommandBuilder> args = buildArgs(xs, ys, zs);
    CommandBuilder target = newBuilder(prog(progName), args);

    String[] actual = target.tokens().toArray(String[]::new);
    String[] expected = concat(new String[] {progName}, xs, ys, zs);
    assertArrayEquals(expected, actual);
  }
Пример #2
0
  public DrawCommand buildCommand(final String input) {
    String trimmedInput = input.trim();
    if (trimmedInput.isEmpty()) {
      throw new IllegalArgumentException("A command must be provided");
    }

    String command = trimmedInput.split(" ")[0].toUpperCase();

    CommandBuilder commandBuilder = drawOptions.get(command);

    if (commandBuilder == null) {
      throw new IllegalArgumentException("The command '" + command + "' is not supported");
    }

    return commandBuilder.create(trimmedInput);
  }