CombinedSingleHostServerExposer implements ExternalServerExposer<T> { @Override public void expose( T k8sEnv, String machineName, String serviceName, String serverId, ServicePort servicePort, Map<String, ServerConfig> externalServers) { if (serverId == null) { serverId = servicePort.getName(); } Map<String, ServerConfig> subpathServers = new HashMap<>(); Map<String, ServerConfig> subdomainServers = new HashMap<>(); for (String esKey : externalServers.keySet()) { ServerConfig serverConfig = externalServers.get(esKey); if (Boolean.parseBoolean( serverConfig.getAttributes().getOrDefault(REQUIRE_SUBDOMAIN, FALSE.toString()))) { subdomainServers.put(esKey, serverConfig); } else { subpathServers.put(esKey, serverConfig); } } if (!subpathServers.isEmpty()) { subpathServerExposer.expose( k8sEnv, machineName, serviceName, serverId, servicePort, subpathServers); } if (!subdomainServers.isEmpty()) { subdomainServerExposer.expose( k8sEnv, machineName, serviceName, serverId, servicePort, subdomainServers); } } CombinedSingleHostServerExposer(
      ExternalServerExposer<T> subdomainServerExposer,
      ExternalServerExposer<T> subpathServerExposer); @Override void expose(
      T k8sEnv,
      String machineName,
      String serviceName,
      String serverId,
      ServicePort servicePort,
      Map<String, ServerConfig> externalServers);  }
@Test public void shouldExposeDevfileServersOnSubdomans() { ServerConfig s1 = new ServerConfigImpl("1", "http", "/", emptyMap()); ServerConfig s2 = new ServerConfigImpl("2", "http", "/", singletonMap(REQUIRE_SUBDOMAIN, "false")); ServerConfig s3 = new ServerConfigImpl("3", "http", "/", singletonMap(REQUIRE_SUBDOMAIN, "true")); CombinedSingleHostServerExposer<KubernetesEnvironment> serverExposer = new CombinedSingleHostServerExposer<>(subdomainExposer, subpathExposer); serverExposer.expose(env, MACHINE, SERVICE, SERVER, PORT, Map.of("s1", s1, "s2", s2, "s3", s3)); verify(subdomainExposer).expose(env, MACHINE, SERVICE, SERVER, PORT, Map.of("s3", s3)); verify(subpathExposer).expose(env, MACHINE, SERVICE, SERVER, PORT, Map.of("s1", s1, "s2", s2)); }