GatewayServerExposer implements ExternalServerExposer<T> { @Override public void expose( T k8sEnv, @Nullable String machineName, String serviceName, String serverId, ServicePort servicePort, Map<String, ServerConfig> externalServers) { if (serverId == null) { serverId = servicePort.getName(); } for (String esKey : externalServers.keySet()) { final String serverName = KubernetesServerExposer.makeServerNameValidForDns(serverId); final String name = createName(serviceName, serverName); k8sEnv .getConfigMaps() .put( name, createGatewayRouteConfigmap( name, machineName, serviceName, servicePort, serverName, esKey, externalServers.get(esKey))); } } @Inject  GatewayServerExposer(
      ExternalServiceExposureStrategy strategy, GatewayConfigmapLabels configmapLabels); @Override void expose(
      T k8sEnv,
      @Nullable String machineName,
      String serviceName,
      String serverId,
      ServicePort servicePort,
      Map<String, ServerConfig> externalServers);  }
@Test public void testExposeServiceWithGatewayConfigmap() { KubernetesEnvironment k8sEnv = KubernetesEnvironment.builder().build(); serverExposer.expose(k8sEnv, machineName, serviceName, serverId, servicePort, servers); Map<String, ConfigMap> configMaps = k8sEnv.getConfigMaps(); assertTrue(configMaps.containsKey(serviceName + "-" + serverId)); ConfigMap serverConfigMap = configMaps.get("service-server"); assertTrue(serverConfigMap.getData() == null || serverConfigMap.getData().isEmpty()); assertEquals(serverConfigMap.getMetadata().getLabels(), GATEWAY_CONFIGMAP_LABELS); Map<String, String> annotations = serverConfigMap.getMetadata().getAnnotations(); Annotations.Deserializer deserializer = Annotations.newDeserializer(annotations); assertEquals(deserializer.machineName(), machineName); Map<String, ServerConfigImpl> exposedServers = deserializer.servers(); assertTrue(exposedServers.containsKey("serverOne")); ServerConfig s1 = exposedServers.get("serverOne"); assertEquals( s1.getAttributes().get(s1attrs.keySet().iterator().next()), s1attrs.values().iterator().next()); assertEquals(s1.getAttributes().get(ServerConfigImpl.SERVICE_NAME_ATTRIBUTE), "service"); assertEquals(s1.getAttributes().get(ServerConfigImpl.SERVICE_PORT_ATTRIBUTE), "1234"); assertEquals(s1.getPort(), "1111"); assertEquals(s1.getProtocol(), "ws"); assertEquals(s1.getPath(), "/service/server/"); }