ServiceOperator extends AbstractResourceOperator<KubernetesClient, Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> { protected void patchHealthCheckPorts(Service current, Service desired) { if (current.getSpec().getHealthCheckNodePort() != null && desired.getSpec().getHealthCheckNodePort() == null) { desired.getSpec().setHealthCheckNodePort(current.getSpec().getHealthCheckNodePort()); } } ServiceOperator(Vertx vertx, KubernetesClient client); Future<Void> endpointReadiness(String namespace, String name, long pollInterval, long operationTimeoutMs); Future<Void> hasIngressAddress(String namespace, String name, long pollIntervalMs, long timeoutMs); boolean isIngressAddressReady(String namespace, String name); Future<Void> hasNodePort(String namespace, String name, long pollIntervalMs, long timeoutMs); boolean isNodePortReady(String namespace, String name);  }
@Test public void testHealthCheckPortPatching() { KubernetesClient client = mock(KubernetesClient.class); Service current = new ServiceBuilder() .withNewMetadata() .withNamespace(NAMESPACE) .withName(RESOURCE_NAME) .endMetadata() .withNewSpec() .withType("Loadbalancer") .withHealthCheckNodePort(34321) .endSpec() .build(); Service desired = new ServiceBuilder() .withNewMetadata() .withNamespace(NAMESPACE) .withName(RESOURCE_NAME) .endMetadata() .withNewSpec() .withType("Loadbalancer") .endSpec() .build(); ServiceOperator op = new ServiceOperator(vertx, client); op.patchHealthCheckPorts(current, desired); assertThat(current.getSpec().getHealthCheckNodePort(), is(desired.getSpec().getHealthCheckNodePort())); }