@VisibleForTesting
  static String truncateLongClasspath(ImmutableList<String> imageEntrypoint) {
    List<String> truncated = new ArrayList<>();
    UnmodifiableIterator<String> iterator = imageEntrypoint.iterator();
    while (iterator.hasNext()) {
      String element = iterator.next();
      truncated.add(element);

      if (element.equals("-cp") || element.equals("-classpath")) {
        String classpath = iterator.next();
        if (classpath.length() > 200) {
          truncated.add(classpath.substring(0, 200) + "<... classpath truncated ...>");
        } else {
          truncated.add(classpath);
        }
      }
    }
    return truncated.toString();
  }
@Test
  public void testTruncateLongClasspath_longClasspath() {
    String classpath =
        "/app/resources:/app/classes:/app/libs/spring-boot-starter-web-2.0.3.RELEASE.jar:/app/libs/"
            + "shared-library-0.1.0.jar:/app/libs/spring-boot-starter-json-2.0.3.RELEASE.jar:/app/"
            + "libs/spring-boot-starter-2.0.3.RELEASE.jar:/app/libs/spring-boot-starter-tomcat-2.0."
            + "3.RELEASE.jar";
    ImmutableList<String> entrypoint =
        ImmutableList.of("java", "-Dmy-property=value", "-cp", classpath, "com.example.Main");

    Assert.assertEquals(
        "[java, -Dmy-property=value, -cp, /app/resources:/app/classes:/app/libs/spring-boot-starter"
            + "-web-2.0.3.RELEASE.jar:/app/libs/shared-library-0.1.0.jar:/app/libs/spring-boot-"
            + "starter-json-2.0.3.RELEASE.jar:/app/libs/spring-boot-starter-2.<... classpath "
            + "truncated ...>, com.example.Main]",
        BuildImageStep.truncateLongClasspath(entrypoint));
  }