ListenersConvertor { static GenericKafkaListener convertExternalListener(KafkaListenerExternal external) { GenericKafkaListener listener = new GenericKafkaListenerBuilder() .withName("external") .withPort(9094) .withAuth(external.getAuth()) .withNetworkPolicyPeers(external.getNetworkPolicyPeers()) .build(); if (KafkaListenerExternalLoadBalancer.TYPE_LOADBALANCER.equals(external.getType())) { convertLoadBalancerListener(listener, (KafkaListenerExternalLoadBalancer) external); } else if (KafkaListenerExternalNodePort.TYPE_NODEPORT.equals(external.getType())) { convertNodePortListener(listener, (KafkaListenerExternalNodePort) external); } else if (KafkaListenerExternalRoute.TYPE_ROUTE.equals(external.getType())) { convertRouteListener(listener, (KafkaListenerExternalRoute) external); } else if (KafkaListenerExternalIngress.TYPE_INGRESS.equals(external.getType())) { convertIngressListener(listener, (KafkaListenerExternalIngress) external); } return listener; }  @SuppressWarnings("deprecation") static List<GenericKafkaListener> convertToNewFormat(KafkaListeners oldListeners);  }
@Test public void testConvertSimpleRouteListener() { KafkaListenerExternal oldListener = new KafkaListenerExternalRouteBuilder() .build(); GenericKafkaListener newListener = ListenersConvertor.convertExternalListener(oldListener); assertThat(newListener.getName(), is("external")); assertThat(newListener.getPort(), is(9094)); assertThat(newListener.getType(), is(KafkaListenerType.ROUTE)); assertThat(newListener.getAuth(), is(nullValue())); assertThat(newListener.isTls(), is(true)); assertThat(newListener.getNetworkPolicyPeers(), is(nullValue())); assertThat(newListener.getConfiguration(), is(nullValue())); }
@Test public void testConvertSimpleLoadBalancerListener() { KafkaListenerExternal oldListener = new KafkaListenerExternalLoadBalancerBuilder() .build(); GenericKafkaListener newListener = ListenersConvertor.convertExternalListener(oldListener); assertThat(newListener.getName(), is("external")); assertThat(newListener.getPort(), is(9094)); assertThat(newListener.getType(), is(KafkaListenerType.LOADBALANCER)); assertThat(newListener.getAuth(), is(nullValue())); assertThat(newListener.isTls(), is(true)); assertThat(newListener.getNetworkPolicyPeers(), is(nullValue())); assertThat(newListener.getConfiguration(), is(nullValue())); }
@Test public void testConvertSimpleNodePortListener() { KafkaListenerExternal oldListener = new KafkaListenerExternalNodePortBuilder() .build(); GenericKafkaListener newListener = ListenersConvertor.convertExternalListener(oldListener); assertThat(newListener.getName(), is("external")); assertThat(newListener.getPort(), is(9094)); assertThat(newListener.getType(), is(KafkaListenerType.NODEPORT)); assertThat(newListener.getAuth(), is(nullValue())); assertThat(newListener.isTls(), is(true)); assertThat(newListener.getNetworkPolicyPeers(), is(nullValue())); assertThat(newListener.getConfiguration(), is(nullValue())); }
@Test public void testConvertSimpleIngressListener() { KafkaListenerExternal oldListener = new KafkaListenerExternalIngressBuilder() .build(); GenericKafkaListener newListener = ListenersConvertor.convertExternalListener(oldListener); assertThat(newListener.getName(), is("external")); assertThat(newListener.getPort(), is(9094)); assertThat(newListener.getType(), is(KafkaListenerType.INGRESS)); assertThat(newListener.getAuth(), is(nullValue())); assertThat(newListener.isTls(), is(true)); assertThat(newListener.getNetworkPolicyPeers(), is(nullValue())); assertThat(newListener.getConfiguration(), is(nullValue())); }