@Test void testStatusIsUpWhenCatalogAndDiscoveryAreAvailable() { when(providers.isZosfmUsed()).thenReturn(false); DiscoveryClient discoveryClient = mock(DiscoveryClient.class); when(discoveryClient.getInstances(CoreService.API_CATALOG.getServiceId())).thenReturn( Collections.singletonList(new DefaultServiceInstance(CoreService.API_CATALOG.getServiceId(), "host", 10014, true))); when(discoveryClient.getInstances(CoreService.DISCOVERY.getServiceId())).thenReturn( Collections.singletonList(new DefaultServiceInstance(CoreService.DISCOVERY.getServiceId(), "host", 10011, true))); GatewayHealthIndicator gatewayHealthIndicator = new GatewayHealthIndicator(discoveryClient, providers); Health.Builder builder = new Health.Builder(); gatewayHealthIndicator.doHealthCheck(builder); assertEquals(Status.UP, builder.build().getStatus()); }
@Override protected void doHealthCheck(Health.Builder builder) { boolean apiCatalogUp = !this.discoveryClient.getInstances(CoreService.API_CATALOG.getServiceId()).isEmpty(); boolean discoveryUp = !this.discoveryClient.getInstances(CoreService.DISCOVERY.getServiceId()).isEmpty(); boolean authUp = true; if (loginProviders.isZosfmUsed()) { try { authUp = loginProviders.isZosmfAvailable(); } catch (AuthenticationServiceException ex) { System.exit(-1); } } int gatewayCount = this.discoveryClient.getInstances(CoreService.GATEWAY.getServiceId()).size(); builder.status(toStatus(discoveryUp)) .withDetail(CoreService.API_CATALOG.getServiceId(), toStatus(apiCatalogUp).getCode()) .withDetail(CoreService.DISCOVERY.getServiceId(), toStatus(discoveryUp).getCode()) .withDetail(CoreService.AUTH.getServiceId(), toStatus(authUp).getCode()) .withDetail("gatewayCount", gatewayCount); }
GatewayHealthIndicator extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) { boolean apiCatalogUp = !this.discoveryClient.getInstances(CoreService.API_CATALOG.getServiceId()).isEmpty(); boolean discoveryUp = !this.discoveryClient.getInstances(CoreService.DISCOVERY.getServiceId()).isEmpty(); boolean authUp = true; if (loginProviders.isZosfmUsed()) { try { authUp = loginProviders.isZosmfAvailable(); } catch (AuthenticationServiceException ex) { System.exit(-1); } } int gatewayCount = this.discoveryClient.getInstances(CoreService.GATEWAY.getServiceId()).size(); builder.status(toStatus(discoveryUp)) .withDetail(CoreService.API_CATALOG.getServiceId(), toStatus(apiCatalogUp).getCode()) .withDetail(CoreService.DISCOVERY.getServiceId(), toStatus(discoveryUp).getCode()) .withDetail(CoreService.AUTH.getServiceId(), toStatus(authUp).getCode()) .withDetail("gatewayCount", gatewayCount); } }
GatewayHealthIndicator extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) { boolean apiCatalogUp = !this.discoveryClient.getInstances(CoreService.API_CATALOG.getServiceId()).isEmpty(); boolean discoveryUp = !this.discoveryClient.getInstances(CoreService.DISCOVERY.getServiceId()).isEmpty(); boolean authUp = true; if (loginProviders.isZosfmUsed()) { try { authUp = loginProviders.isZosmfAvailable(); } catch (AuthenticationServiceException ex) { System.exit(-1); } } int gatewayCount = this.discoveryClient.getInstances(CoreService.GATEWAY.getServiceId()).size(); builder.status(toStatus(discoveryUp)) .withDetail(CoreService.API_CATALOG.getServiceId(), toStatus(apiCatalogUp).getCode()) .withDetail(CoreService.DISCOVERY.getServiceId(), toStatus(discoveryUp).getCode()) .withDetail(CoreService.AUTH.getServiceId(), toStatus(authUp).getCode()) .withDetail("gatewayCount", gatewayCount); }  }
GatewayHealthIndicator extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) { boolean apiCatalogUp = !this.discoveryClient.getInstances(CoreService.API_CATALOG.getServiceId()).isEmpty(); boolean discoveryUp = !this.discoveryClient.getInstances(CoreService.DISCOVERY.getServiceId()).isEmpty(); boolean authUp = true; if (loginProviders.isZosfmUsed()) { try { authUp = loginProviders.isZosmfAvailable(); } catch (AuthenticationServiceException ex) { System.exit(-1); } } int gatewayCount = this.discoveryClient.getInstances(CoreService.GATEWAY.getServiceId()).size(); builder.status(toStatus(discoveryUp)) .withDetail(CoreService.API_CATALOG.getServiceId(), toStatus(apiCatalogUp).getCode()) .withDetail(CoreService.DISCOVERY.getServiceId(), toStatus(discoveryUp).getCode()) .withDetail(CoreService.AUTH.getServiceId(), toStatus(authUp).getCode()) .withDetail("gatewayCount", gatewayCount); }   }
GatewayHealthIndicator extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) { boolean apiCatalogUp = !this.discoveryClient.getInstances(CoreService.API_CATALOG.getServiceId()).isEmpty(); boolean discoveryUp = !this.discoveryClient.getInstances(CoreService.DISCOVERY.getServiceId()).isEmpty(); boolean authUp = true; if (loginProviders.isZosfmUsed()) { try { authUp = loginProviders.isZosmfAvailable(); } catch (AuthenticationServiceException ex) { System.exit(-1); } } int gatewayCount = this.discoveryClient.getInstances(CoreService.GATEWAY.getServiceId()).size(); builder.status(toStatus(discoveryUp)) .withDetail(CoreService.API_CATALOG.getServiceId(), toStatus(apiCatalogUp).getCode()) .withDetail(CoreService.DISCOVERY.getServiceId(), toStatus(discoveryUp).getCode()) .withDetail(CoreService.AUTH.getServiceId(), toStatus(authUp).getCode()) .withDetail("gatewayCount", gatewayCount); }    }