KafkaBridgeCluster extends AbstractModel { public Service generateService() { List<ServicePort> ports = new ArrayList<>(3); int port = DEFAULT_REST_API_PORT; if (http != null) { port = http.getPort(); } ports.add(createServicePort(REST_API_PORT_NAME, port, port, "TCP")); return createDiscoverableService("ClusterIP", ports, Util.mergeLabelsOrAnnotations(getDiscoveryAnnotation(port), templateServiceAnnotations, ModelUtils.getCustomLabelsOrAnnotations(CO_ENV_VAR_CUSTOM_ANNOTATIONS))); } protected  KafkaBridgeCluster(HasMetadata resource); static KafkaBridgeCluster fromCrd(KafkaBridge kafkaBridge, KafkaVersion.Lookup versions); Service generateService(); Deployment generateDeployment(Map<String, String> annotations, boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets); @Override String getAncillaryConfigMapKeyLogConfig(); PodDisruptionBudget generatePodDisruptionBudget(); KafkaBridgeHttpConfig getHttp(); @Override String createLog4jProperties(OrderedProperties properties); static final String APPLICATION_NAME; static final int DEFAULT_REST_API_PORT; static final Probe DEFAULT_HEALTHCHECK_OPTIONS; }
@Test public void testGenerateService() { Service svc = kbc.generateService(); assertThat(svc.getSpec().getType(), is("ClusterIP")); assertThat(svc.getMetadata().getLabels(), is(expectedServiceLabels(kbc.getName()))); assertThat(svc.getSpec().getSelector(), is(expectedSelectorLabels())); assertThat(svc.getSpec().getPorts().size(), is(1)); assertThat(svc.getSpec().getPorts().get(0).getPort(), is(Integer.valueOf(KafkaBridgeCluster.DEFAULT_REST_API_PORT))); assertThat(svc.getSpec().getPorts().get(0).getName(), is(KafkaBridgeCluster.REST_API_PORT_NAME)); assertThat(svc.getSpec().getPorts().get(0).getProtocol(), is("TCP")); assertThat(svc.getMetadata().getAnnotations(), is(kbc.getDiscoveryAnnotation(KafkaBridgeCluster.DEFAULT_REST_API_PORT))); checkOwnerReference(kbc.createOwnerReference(), svc); }