ListenersConvertor { static GenericKafkaListener convertPlainListener(KafkaListenerPlain plain) { return new GenericKafkaListenerBuilder() .withName("plain") .withPort(9092) .withType(KafkaListenerType.INTERNAL) .withTls(false) .withAuth(plain.getAuth()) .withNetworkPolicyPeers(plain.getNetworkPolicyPeers()) .build(); }  @SuppressWarnings("deprecation") static List<GenericKafkaListener> convertToNewFormat(KafkaListeners oldListeners);  }
@Test public void testConvertSimplePlainListener() { KafkaListenerPlain oldPlain = new KafkaListenerPlainBuilder() .build(); GenericKafkaListener newPlain = ListenersConvertor.convertPlainListener(oldPlain); assertThat(newPlain.getName(), is("plain")); assertThat(newPlain.getPort(), is(9092)); assertThat(newPlain.getType(), is(KafkaListenerType.INTERNAL)); assertThat(newPlain.getAuth(), is(nullValue())); assertThat(newPlain.isTls(), is(false)); assertThat(newPlain.getNetworkPolicyPeers(), is(nullValue())); assertThat(newPlain.getConfiguration(), is(nullValue())); }
@Test public void testConvertPlainListener() { KafkaListenerPlain oldPlain = new KafkaListenerPlainBuilder() .withAuth(new KafkaListenerAuthenticationScramSha512()) .withNetworkPolicyPeers(NETWORK_POLICY_PEER_1, NETWORK_POLICY_PEER_2) .build(); GenericKafkaListener newPlain = ListenersConvertor.convertPlainListener(oldPlain); assertThat(newPlain.getName(), is("plain")); assertThat(newPlain.getPort(), is(9092)); assertThat(newPlain.getType(), is(KafkaListenerType.INTERNAL)); assertThat(newPlain.getAuth().getType(), is(KafkaListenerAuthenticationScramSha512.SCRAM_SHA_512)); assertThat(newPlain.isTls(), is(false)); assertThat(newPlain.getNetworkPolicyPeers().size(), is(2)); assertThat(newPlain.getNetworkPolicyPeers(), hasItems(NETWORK_POLICY_PEER_1, NETWORK_POLICY_PEER_2)); assertThat(newPlain.getConfiguration(), is(nullValue())); }