@Test
  public void testCliParser() throws Exception {
    List<String> sparkSubmitArgs =
        Arrays.asList(
            parser.MASTER,
            "local",
            parser.DRIVER_MEMORY,
            "42g",
            parser.DRIVER_CLASS_PATH,
            "/driverCp",
            parser.DRIVER_JAVA_OPTIONS,
            "extraJavaOpt",
            parser.CONF,
            "spark.randomOption=foo",
            parser.CONF,
            SparkLauncher.DRIVER_EXTRA_LIBRARY_PATH + "=/driverLibPath");
    Map<String, String> env = new HashMap<>();
    List<String> cmd = buildCommand(sparkSubmitArgs, env);

    assertTrue(
        findInStringList(
            env.get(CommandBuilderUtils.getLibPathEnvName()),
            File.pathSeparator,
            "/driverLibPath"));
    assertTrue(findInStringList(findArgValue(cmd, "-cp"), File.pathSeparator, "/driverCp"));
    assertTrue("Driver -Xmx should be configured.", cmd.contains("-Xmx42g"));
    assertTrue(
        "Command should contain user-defined conf.",
        Collections.indexOfSubList(cmd, Arrays.asList(parser.CONF, "spark.randomOption=foo")) > 0);
  }
  /**
   * Finds the starting position of the sub array inside the array
   *
   * @param array
   * @param subArray
   * @return index of sub array
   */
  public static int findArray(Integer[] array, Integer[] subArray) {

    if (array.length == 0 || subArray.length == 0) {
      return -1;
    }

    return Collections.indexOfSubList(Arrays.asList(array), Arrays.asList(subArray));
  }
 public static void main(String[] args) {
   print(list);
   print(
       "'list' disjoint (Four)?: "
           + Collections.disjoint(list, Collections.singletonList("Four")));
   print("max: " + Collections.max(list));
   print("min: " + Collections.min(list));
   print("max w/ comparator: " + Collections.max(list, String.CASE_INSENSITIVE_ORDER));
   print("min w/ comparator: " + Collections.min(list, String.CASE_INSENSITIVE_ORDER));
   List<String> sublist = Arrays.asList("Four five six".split(" "));
   print("indexOfSubList: " + Collections.indexOfSubList(list, sublist));
   print("lastIndexOfSubList: " + Collections.lastIndexOfSubList(list, sublist));
   Collections.replaceAll(list, "one", "Yo");
   print("replaceAll: " + list);
   Collections.reverse(list);
   print("reverse: " + list);
   Collections.rotate(list, 3);
   print("rotate: " + list);
   List<String> source = Arrays.asList("in the matrix".split(" "));
   Collections.copy(list, source);
   print("copy: " + list);
   Collections.swap(list, 0, list.size() - 1);
   print("swap: " + list);
   Collections.shuffle(list, new Random(47));
   print("shuffled: " + list);
   Collections.fill(list, "pop");
   print("fill: " + list);
   print("frequency of 'pop': " + Collections.frequency(list, "pop"));
   List<String> dups = Collections.nCopies(3, "snap");
   print("dups: " + dups);
   print("'list' disjoint 'dups'?: " + Collections.disjoint(list, dups));
   // Getting an old-style Enumeration:
   Enumeration<String> e = Collections.enumeration(dups);
   Vector<String> v = new Vector<String>();
   while (e.hasMoreElements()) v.addElement(e.nextElement());
   // Converting an old-style Vector
   // to a List via an Enumeration:
   ArrayList<String> arrayList = Collections.list(v.elements());
   print("arrayList: " + arrayList);
 }
 private List<ActionUrl> findActionsUnderSelection() {
   final ArrayList<ActionUrl> actions = new ArrayList<ActionUrl>();
   final TreePath[] selectionPaths = myActionsTree.getSelectionPaths();
   if (selectionPaths != null) {
     for (TreePath path : selectionPaths) {
       final ActionUrl selectedUrl = CustomizationUtil.getActionUrl(path, ActionUrl.MOVE);
       final ArrayList<String> selectedGroupPath =
           new ArrayList<String>(selectedUrl.getGroupPath());
       final Object component = selectedUrl.getComponent();
       if (component instanceof Group) {
         selectedGroupPath.add(((Group) component).getName());
         for (ActionUrl action : mySelectedSchema.getActions()) {
           final ArrayList<String> groupPath = action.getGroupPath();
           final int idx = Collections.indexOfSubList(groupPath, selectedGroupPath);
           if (idx > -1) {
             actions.add(action);
           }
         }
       }
     }
   }
   return actions;
 }
  /**
   * if building block can be created during choose-process, return true
   *
   * @return
   */
  private boolean isCreateButtonVisible() {
    if (!canCreate) {
      return false;
    }

    final List<String> limitTypeList = Arrays.asList(this.limitTypes);

    final String[] createAllowed =
        new String[] {
          TestFileResource.TYPE_NAME,
          WikiResource.TYPE_NAME,
          ImsCPFileResource.TYPE_NAME,
          SurveyFileResource.TYPE_NAME,
          BlogFileResource.TYPE_NAME,
          PodcastFileResource.TYPE_NAME,
          EPTemplateMapResource.TYPE_NAME
        };

    if (Collections.indexOfSubList(Arrays.asList(createAllowed), limitTypeList) != -1) {
      return true;
    }
    return false;
  }
  /**
   * if building block can be imported, return true
   *
   * @return
   */
  private boolean isImportButtonVisible() {
    if (!canImport) {
      return false;
    }

    final List<String> limitTypeList = Arrays.asList(this.limitTypes);

    final String[] importAllowed =
        new String[] {
          TestFileResource.TYPE_NAME,
          WikiResource.TYPE_NAME,
          ImsCPFileResource.TYPE_NAME,
          ScormCPFileResource.TYPE_NAME,
          SurveyFileResource.TYPE_NAME,
          BlogFileResource.TYPE_NAME,
          PodcastFileResource.TYPE_NAME
        };

    if (Collections.indexOfSubList(Arrays.asList(importAllowed), limitTypeList) != -1) {
      return true;
    }

    return false;
  }