ListenersUtils { public static String backwardsCompatiblePortName(GenericKafkaListener listener) { if (listener.getPort() == 9092 && "plain".equals(listener.getName()) && KafkaListenerType.INTERNAL == listener.getType()) { return BACKWARDS_COMPATIBLE_PLAIN_PORT_NAME; } else if (listener.getPort() == 9093 && "tls".equals(listener.getName()) && KafkaListenerType.INTERNAL == listener.getType()) { return BACKWARDS_COMPATIBLE_TLS_PORT_NAME; } else if (listener.getPort() == 9094 && "external".equals(listener.getName())) { return BACKWARDS_COMPATIBLE_EXTERNAL_PORT_NAME; } else { return "tcp-" + listener.getName(); } }  static boolean hasListenerWithOAuth(List<GenericKafkaListener> listeners); static List<GenericKafkaListener> internalListeners(List<GenericKafkaListener> listeners); static List<GenericKafkaListener> externalListeners(List<GenericKafkaListener> listeners); static List<GenericKafkaListener> routeListeners(List<GenericKafkaListener> listeners); static List<GenericKafkaListener> loadBalancerListeners(List<GenericKafkaListener> listeners); static List<GenericKafkaListener> nodePortListeners(List<GenericKafkaListener> listeners); static List<GenericKafkaListener> ingressListeners(List<GenericKafkaListener> listeners); static boolean hasExternalListener(List<GenericKafkaListener> listeners); static boolean hasRouteListener(List<GenericKafkaListener> listeners); static boolean hasLoadBalancerListener(List<GenericKafkaListener> listeners); static boolean hasNodePortListener(List<GenericKafkaListener> listeners); static boolean hasIngressListener(List<GenericKafkaListener> listeners); static List<String> alternativeNames(List<GenericKafkaListener> listeners); static String identifier(GenericKafkaListener listener); static String envVarIdentifier(GenericKafkaListener listener); static String backwardsCompatiblePortName(GenericKafkaListener listener); static String backwardsCompatibleBootstrapServiceName(String clusterName, GenericKafkaListener listener); static String backwardsCompatibleBootstrapRouteOrIngressName(String clusterName, GenericKafkaListener listener); static String backwardsCompatibleBrokerServiceName(String clusterName, int pod, GenericKafkaListener listener); static Integer bootstrapNodePort(GenericKafkaListener listener); static Integer brokerNodePort(GenericKafkaListener listener, int pod); static String bootstrapLoadBalancerIP(GenericKafkaListener listener); static String brokerLoadBalancerIP(GenericKafkaListener listener, int pod); static Map<String, String> bootstrapAnnotations(GenericKafkaListener listener); static Map<String, String> brokerAnnotations(GenericKafkaListener listener, int pod); static String bootstrapHost(GenericKafkaListener listener); static String brokerHost(GenericKafkaListener listener, int pod); static String brokerAdvertisedHost(GenericKafkaListener listener, int pod); static Integer brokerAdvertisedPort(GenericKafkaListener listener, int pod); static List<String> loadBalancerSourceRanges(GenericKafkaListener listener); static ExternalTrafficPolicy externalTrafficPolicy(GenericKafkaListener listener); static NodeAddressType preferredNodeAddressType(GenericKafkaListener listener); static String ingressClass(GenericKafkaListener listener); static String serviceType(GenericKafkaListener listener);  }
@Test public void testBackwardsCompatiblePortName() { assertThat(ListenersUtils.backwardsCompatiblePortName(oldPlain), is("tcp-clients")); assertThat(ListenersUtils.backwardsCompatiblePortName(oldTls), is("tcp-clientstls")); assertThat(ListenersUtils.backwardsCompatiblePortName(oldExternal), is("tcp-external")); assertThat(ListenersUtils.backwardsCompatiblePortName(newPlain), is("tcp-plain2")); assertThat(ListenersUtils.backwardsCompatiblePortName(newTls), is("tcp-tls2")); assertThat(ListenersUtils.backwardsCompatiblePortName(newLoadBalancer), is("tcp-lb1")); }