ListenersUtils { public static String backwardsCompatibleBootstrapRouteOrIngressName(String clusterName, GenericKafkaListener listener) { if (listener.getPort() == 9092 && "plain".equals(listener.getName()) && KafkaListenerType.INTERNAL == listener.getType()) { throw new UnsupportedOperationException("Bootstrap routes or ingresses are not used for internal listeners"); } else if (listener.getPort() == 9093 && "tls".equals(listener.getName()) && KafkaListenerType.INTERNAL == listener.getType()) { throw new UnsupportedOperationException("Bootstrap routes or ingresses are not used for internal listeners"); } else if (listener.getPort() == 9094 && "external".equals(listener.getName())) { return clusterName + "-kafka-bootstrap"; } else if (KafkaListenerType.INTERNAL == listener.getType()) { throw new UnsupportedOperationException("Bootstrap routes or ingresses are not used for internal listeners"); } else { return clusterName + "-kafka-" + listener.getName() + "-bootstrap"; } }  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 testBackwardsCompatibleBootstrapRouteOrIngressName() { String clusterName = "my-cluster"; assertThrows(UnsupportedOperationException.class, () -> ListenersUtils.backwardsCompatibleBootstrapRouteOrIngressName(clusterName, oldPlain)); assertThrows(UnsupportedOperationException.class, () -> ListenersUtils.backwardsCompatibleBootstrapRouteOrIngressName(clusterName, oldTls)); assertThrows(UnsupportedOperationException.class, () -> ListenersUtils.backwardsCompatibleBootstrapRouteOrIngressName(clusterName, newPlain)); assertThrows(UnsupportedOperationException.class, () -> ListenersUtils.backwardsCompatibleBootstrapRouteOrIngressName(clusterName, newTls)); assertThat(ListenersUtils.backwardsCompatibleBootstrapRouteOrIngressName(clusterName, oldExternal), is(clusterName + "-kafka-bootstrap")); assertThat(ListenersUtils.backwardsCompatibleBootstrapRouteOrIngressName(clusterName, newLoadBalancer), is(clusterName + "-kafka-lb1-bootstrap")); assertThat(ListenersUtils.backwardsCompatibleBootstrapRouteOrIngressName(clusterName, newNodePort), is(clusterName + "-kafka-np1-bootstrap")); assertThat(ListenersUtils.backwardsCompatibleBootstrapRouteOrIngressName(clusterName, newRoute), is(clusterName + "-kafka-route-bootstrap")); }