// Path: spydra/src/test/java/com/spotify/spydra/CliTestHelpers.java
// public class CliTestHelpers {
//   public static <T> void ensureAllThrow(CliParser<T> parser, List<String[]> argsList, Class exceptionCls) {
//     for (String[] args : argsList) {
//       String errorMsg = "Should throw for: " + String.join(";", args);
//       assertTrue(errorMsg, checkThrows(parser, args, exceptionCls));
//     }
//   }
// 
//   public static <T> boolean checkThrows(CliParser<T> parser, String[] args, Class exceptionCls) {
//     boolean threw = false;
// 
//     try {
//       parser.parse(args);
//     } catch (Exception e) {
//       if (exceptionCls.isInstance(e)) {
//         threw = true;
//       }
//     }
//     return threw;
//   }
// 
//   public static String toStrOpt(String optionName, String optionValue) {
//     return String.format("--%s=%s", optionName, optionValue);
//   }
// }
// 
// Path: spydra/src/main/java/com/spotify/spydra/historytools/commands/DumpLogsCommand.java
// @AutoValue
// public abstract class DumpLogsCommand {
// 
//   DumpLogsCommand() {
//   }
// 
//   public abstract String clientId();
// 
//   public abstract ApplicationId applicationId();
// 
//   public abstract String username();
// 
//   public abstract String logBucket();
// 
//   public static Builder builder() {
//     return new AutoValue_DumpLogsCommand.Builder();
//   }
// 
//   @AutoValue.Builder
//   public abstract static class Builder {
//     public abstract Builder clientId(String clientId);
// 
//     public abstract Builder applicationId(ApplicationId jobId);
// 
//     public abstract Builder username(String username);
// 
//     public abstract Builder logBucket(String logBucket);
// 
//     public abstract DumpLogsCommand build();
//   }
// }
// 
// Path: spydra/src/main/java/com/spotify/spydra/submitter/runner/CliConsts.java
// public class CliConsts {
//   public static final String SUBMIT_CMD_NAME = "submit";
//   public static final String LOGS_CMD_NAME = "dump-logs";
//   public static final String DUMP_HISTORY_CMD_NAME = "dump-history";
//   public static final String RUN_JHS_CMD_NAME = "run-jhs";
//   public static final String JOB_ID_OPTION_NAME = "application";
//   public static final String CLIENT_ID_OPTION_NAME = "clientid";
//   public static final String JAR_OPTION_NAME = "jar";
//   public static final String JARS_OPTION_NAME = "jars";
//   public static final String SPYDRA_JSON_OPTION_NAME = "spydra-json";
//   public static final String USERNAME_OPTION_NAME = "username";
//   public static final String LOG_BUCKET_OPTION_NAME = "log-bucket";
//   public static final String JOBNAME_OPTION_NAME = "job-name";
// }
// 
// Path: spydra/src/main/java/com/spotify/spydra/submitter/runner/CliParser.java
// public interface CliParser<T> {
// 
//   T parse(String[] args) throws IOException;
// 
//   /**
//    * Prints help for the subcommand this parser is responsible for.
//    */
//   void printHelp();
// 
//   boolean enoughArgs(String[] args);
// 
//   class ParsingException extends RuntimeException {
//     public ParsingException(Throwable cause) {
//       super(cause);
//     }
//   }
// }


import static org.junit.Assert.assertEquals;
import com.spotify.spydra.CliTestHelpers;
import com.spotify.spydra.historytools.commands.DumpLogsCommand;
import com.spotify.spydra.submitter.runner.CliConsts;
import com.spotify.spydra.submitter.runner.CliParser;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
  public void testParse() {
    DumpLogsCommand dumpCmd = PARSER.parse(new String[]{
        CliTestHelpers.toStrOpt(CliConsts.JOB_ID_OPTION_NAME, DUMMY_APP_ID),
        CliTestHelpers.toStrOpt(CliConsts.CLIENT_ID_OPTION_NAME, DUMMY_CLIENT_ID),
        CliTestHelpers.toStrOpt(CliConsts.USERNAME_OPTION_NAME, DUMMY_USER),
        CliTestHelpers.toStrOpt(CliConsts.LOG_BUCKET_OPTION_NAME, DUMMY_BUCKET)
    });

    assertEquals(dumpCmd.applicationId().toString(), DUMMY_APP_ID);
    assertEquals(dumpCmd.clientId(), DUMMY_CLIENT_ID);
    assertEquals(dumpCmd.username(), DUMMY_USER);
    assertEquals(dumpCmd.logBucket(), DUMMY_BUCKET);
  }

  @Test
  public void testMissingArgs() {
    // Ensure options are mandatory
    List<String[]> failingLines = Arrays.asList(
        new String[]{
            CliTestHelpers.toStrOpt(CliConsts.CLIENT_ID_OPTION_NAME, DUMMY_CLIENT_ID)
        },
        new String[]{
            CliTestHelpers.toStrOpt(CliConsts.JOB_ID_OPTION_NAME, DUMMY_APP_ID)
        },
        new String[]{
            CliTestHelpers.toStrOpt(CliConsts.USERNAME_OPTION_NAME, DUMMY_USER)
        },
        new String[]{
            CliTestHelpers.toStrOpt(CliConsts.CLIENT_ID_OPTION_NAME, DUMMY_CLIENT_ID),
            CliTestHelpers.toStrOpt(CliConsts.JOB_ID_OPTION_NAME, DUMMY_APP_ID),
// Path: spydra/src/test/java/com/spotify/spydra/CliTestHelpers.java
// public class CliTestHelpers {
//   public static <T> void ensureAllThrow(CliParser<T> parser, List<String[]> argsList, Class exceptionCls) {
//     for (String[] args : argsList) {
//       String errorMsg = "Should throw for: " + String.join(";", args);
//       assertTrue(errorMsg, checkThrows(parser, args, exceptionCls));
//     }
//   }
// 
//   public static <T> boolean checkThrows(CliParser<T> parser, String[] args, Class exceptionCls) {
//     boolean threw = false;
// 
//     try {
//       parser.parse(args);
//     } catch (Exception e) {
//       if (exceptionCls.isInstance(e)) {
//         threw = true;
//       }
//     }
//     return threw;
//   }
// 
//   public static String toStrOpt(String optionName, String optionValue) {
//     return String.format("--%s=%s", optionName, optionValue);
//   }
// }
// 
// Path: spydra/src/main/java/com/spotify/spydra/historytools/commands/DumpLogsCommand.java
// @AutoValue
// public abstract class DumpLogsCommand {
// 
//   DumpLogsCommand() {
//   }
// 
//   public abstract String clientId();
// 
//   public abstract ApplicationId applicationId();
// 
//   public abstract String username();
// 
//   public abstract String logBucket();
// 
//   public static Builder builder() {
//     return new AutoValue_DumpLogsCommand.Builder();
//   }
// 
//   @AutoValue.Builder
//   public abstract static class Builder {
//     public abstract Builder clientId(String clientId);
// 
//     public abstract Builder applicationId(ApplicationId jobId);
// 
//     public abstract Builder username(String username);
// 
//     public abstract Builder logBucket(String logBucket);
// 
//     public abstract DumpLogsCommand build();
//   }
// }
// 
// Path: spydra/src/main/java/com/spotify/spydra/submitter/runner/CliConsts.java
// public class CliConsts {
//   public static final String SUBMIT_CMD_NAME = "submit";
//   public static final String LOGS_CMD_NAME = "dump-logs";
//   public static final String DUMP_HISTORY_CMD_NAME = "dump-history";
//   public static final String RUN_JHS_CMD_NAME = "run-jhs";
//   public static final String JOB_ID_OPTION_NAME = "application";
//   public static final String CLIENT_ID_OPTION_NAME = "clientid";
//   public static final String JAR_OPTION_NAME = "jar";
//   public static final String JARS_OPTION_NAME = "jars";
//   public static final String SPYDRA_JSON_OPTION_NAME = "spydra-json";
//   public static final String USERNAME_OPTION_NAME = "username";
//   public static final String LOG_BUCKET_OPTION_NAME = "log-bucket";
//   public static final String JOBNAME_OPTION_NAME = "job-name";
// }
// 
// Path: spydra/src/main/java/com/spotify/spydra/submitter/runner/CliParser.java
// public interface CliParser<T> {
// 
//   T parse(String[] args) throws IOException;
// 
//   /**
//    * Prints help for the subcommand this parser is responsible for.
//    */
//   void printHelp();
// 
//   boolean enoughArgs(String[] args);
// 
//   class ParsingException extends RuntimeException {
//     public ParsingException(Throwable cause) {
//       super(cause);
//     }
//   }
// }


// Path: spydra/src/test/java/com/spotify/spydra/historytools/DumpLogsCliParserTest.java
import static org.junit.Assert.assertEquals;
import com.spotify.spydra.CliTestHelpers;
import com.spotify.spydra.historytools.commands.DumpLogsCommand;
import com.spotify.spydra.submitter.runner.CliConsts;
import com.spotify.spydra.submitter.runner.CliParser;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;

  public void testParse() {
    DumpLogsCommand dumpCmd = PARSER.parse(new String[]{
        CliTestHelpers.toStrOpt(CliConsts.JOB_ID_OPTION_NAME, DUMMY_APP_ID),
        CliTestHelpers.toStrOpt(CliConsts.CLIENT_ID_OPTION_NAME, DUMMY_CLIENT_ID),
        CliTestHelpers.toStrOpt(CliConsts.USERNAME_OPTION_NAME, DUMMY_USER),
        CliTestHelpers.toStrOpt(CliConsts.LOG_BUCKET_OPTION_NAME, DUMMY_BUCKET)
    });

    assertEquals(dumpCmd.applicationId().toString(), DUMMY_APP_ID);
    assertEquals(dumpCmd.clientId(), DUMMY_CLIENT_ID);
    assertEquals(dumpCmd.username(), DUMMY_USER);
    assertEquals(dumpCmd.logBucket(), DUMMY_BUCKET);
  }

  @Test
  public void testMissingArgs() {
    // Ensure options are mandatory
    List<String[]> failingLines = Arrays.asList(
        new String[]{
            CliTestHelpers.toStrOpt(CliConsts.CLIENT_ID_OPTION_NAME, DUMMY_CLIENT_ID)
        },
        new String[]{
            CliTestHelpers.toStrOpt(CliConsts.JOB_ID_OPTION_NAME, DUMMY_APP_ID)
        },
        new String[]{
            CliTestHelpers.toStrOpt(CliConsts.USERNAME_OPTION_NAME, DUMMY_USER)
        },
        new String[]{
            CliTestHelpers.toStrOpt(CliConsts.CLIENT_ID_OPTION_NAME, DUMMY_CLIENT_ID),
            CliTestHelpers.toStrOpt(CliConsts.JOB_ID_OPTION_NAME, DUMMY_APP_ID),
            CliTestHelpers.toStrOpt(CliConsts.USERNAME_OPTION_NAME, DUMMY_USER)