@VisibleForTesting
  String sparkUiWebUrlFromTemplate(String templateString, int port, String serviceName, String serviceDomain) {
    ImmutableMap<String, Object> binding = ImmutableMap.of(
        "PORT", port,
        "SERVICE_NAME", serviceName,
        ENV_SERVICE_DOMAIN, serviceDomain
    );

    ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
    try {
      Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
      Jinjava jinja = new Jinjava();
      return jinja.render(templateString, binding);
    } finally {
      Thread.currentThread().setContextClassLoader(oldCl);
    }
  }
@Test
  void testSparkUiWebUrlTemplate() {
    // given
    Properties properties = new Properties();
    Map<String, String> envs = new HashMap<>();
    envs.put("SERVICE_DOMAIN", "mydomain");

    K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess(
      client,
        "default",
        new File(".skip"),
        "interpreter-container:1.0",
        "shared_process",
        "spark",
        "myspark",
        properties,
        envs,
        "zeppelin.server.service",
        12320,
        false,
        "spark-container:1.0",
        10,
        10,
        false,
        false);

    // when non template url
    assertEquals("static.url",
        intp.sparkUiWebUrlFromTemplate(
            "static.url",
            4040,
            "zeppelin-server",
            "my.domain.com"));

    // when template url
    assertEquals("//4040-zeppelin-server.my.domain.com",
        intp.sparkUiWebUrlFromTemplate(
            "//{{PORT}}-{{SERVICE_NAME}}.{{SERVICE_DOMAIN}}",
            4040,
            "zeppelin-server",
            "my.domain.com"));
    intp.close();
  }