public List<String> toBatchTaskArgumentString() {
    List<String> res = new ArrayList<>(Arrays.asList(
        CLUSTER_LIMIT_FLAG, String.valueOf(mClusterLimit),
        CLUSTER_START_DELAY_FLAG, mClusterStartDelay,
        BENCH_TIMEOUT, mBenchTimeout,
        START_MS_FLAG, String.valueOf(mStartMs)));

    if (!mProfileAgent.isEmpty()) {
      res.add(PROFILE_AGENT);
      res.add(mProfileAgent);
    }

    if (!mId.equals(DEFAULT_TASK_ID)) {
      res.add(ID_FLAG);
      res.add(mId);
    }

    if (!mIndex.equals(DEFAULT_TASK_ID)) {
      res.add(INDEX_FLAG);
      res.add(mIndex);
    }

    if (!mJavaOpts.isEmpty()) {
      for (String s : mJavaOpts) {
        res.add(JAVA_OPT_FLAG);
        res.add(s);
      }
    }

    if (mCluster) {
      res.add(CLUSTER_FLAG);
    }
    if (mDistributed) {
      res.add(DISTRIBUTED_FLAG);
    }
    if (mInProcess) {
      res.add(IN_PROCESS_FLAG);
    }
    if (mHelp) {
      res.add(HELP_FLAG);
    }

    return res;
  }
@Test
  public void parseParameterToArgumentWithJavaOPT() {
    ImmutableList<String> options = ImmutableList.of(" TestOption1", " TestOption2",
        " TestOption3", " TestOption4", " TestOption5");

    List<String> inputArgs = new ArrayList<>(Arrays.asList(
        // keys with values
        "--cluster-limit", "4",
        "--cluster-start-delay", "5s",
        "--id", "TestID",
        // keys with no values
        "--cluster"));

    for (String s : options) {
      inputArgs.add("--java-opt");
      inputArgs.add(s);
    }

    JCommander jc = new JCommander(this);
    jc.parse(inputArgs.toArray(new String[0]));
    List<String> outputArgs = mBaseParameter.toBatchTaskArgumentString();

    // validate the --java-opt
    List<String> optionList = new ArrayList<>();
    for (int i = 0; i < outputArgs.size(); i++) {
      if (outputArgs.get(i).equals(JAVA_OPT_FLAG)) {
        optionList.add(outputArgs.get(i + 1));
      }
    }

    assertEquals(optionList.size(), 5);
    for (String option : optionList) {
      assertTrue(options.contains(option));
    }
  }