@Test public void testServicesDown() { Map<String, Health> healths = new HashMap<>(); IntegrationBridgeServiceInfo agentService = mockIntegrationBridgeService(Status.DOWN, OLD_VERSION, NEW_VERSION, AGENT_URL); IntegrationBridgeServiceInfo podService = mockIntegrationBridgeService(Status.UP, NEW_VERSION, OLD_VERSION, POD_URL); healths.put(AGENT_SERVICE, mockHealth(AGENT_SERVICE, agentService)); healths.put(KM_SERVICE, Health.up().build()); healths.put(POD_SERVICE, mockHealth(POD_SERVICE, podService)); Health result = aggregator.aggregate(healths); Health expected = Health.down() .withDetail(AGENT_SERVICE, agentService) .withDetail(POD_SERVICE, podService) .build(); assertEquals(expected, result); }
@Override public Health aggregate(Map<String, Health> healths) { Health.Builder builder = Health.up(); for (Map.Entry<String, Health> entry : healths.entrySet()) { String serviceName = entry.getKey(); Health health = entry.getValue(); IntegrationBridgeServiceInfo service = (IntegrationBridgeServiceInfo) health.getDetails().get(serviceName); if (service != null) { builder = builder.withDetail(serviceName, service); } if (isServiceDown(health.getStatus(), service)) { builder = builder.down(); } } return builder.build(); }
CompositeServiceHealthAggregator implements HealthAggregator { @Override public Health aggregate(Map<String, Health> healths) { Health.Builder builder = Health.up(); for (Map.Entry<String, Health> entry : healths.entrySet()) { String serviceName = entry.getKey(); Health health = entry.getValue(); IntegrationBridgeServiceInfo service = (IntegrationBridgeServiceInfo) health.getDetails().get(serviceName); if (service != null) { builder = builder.withDetail(serviceName, service); } if (isServiceDown(health.getStatus(), service)) { builder = builder.down(); } } return builder.build(); } }
CompositeServiceHealthAggregator implements HealthAggregator { @Override public Health aggregate(Map<String, Health> healths) { Health.Builder builder = Health.up(); for (Map.Entry<String, Health> entry : healths.entrySet()) { String serviceName = entry.getKey(); Health health = entry.getValue(); IntegrationBridgeServiceInfo service = (IntegrationBridgeServiceInfo) health.getDetails().get(serviceName); if (service != null) { builder = builder.withDetail(serviceName, service); } if (isServiceDown(health.getStatus(), service)) { builder = builder.down(); } } return builder.build(); }  }
CompositeServiceHealthAggregator implements HealthAggregator { @Override public Health aggregate(Map<String, Health> healths) { Health.Builder builder = Health.up(); for (Map.Entry<String, Health> entry : healths.entrySet()) { String serviceName = entry.getKey(); Health health = entry.getValue(); IntegrationBridgeServiceInfo service = (IntegrationBridgeServiceInfo) health.getDetails().get(serviceName); if (service != null) { builder = builder.withDetail(serviceName, service); } if (isServiceDown(health.getStatus(), service)) { builder = builder.down(); } } return builder.build(); }  @Override Health aggregate(Map<String, Health> healths); }
CompositeServiceHealthAggregator implements HealthAggregator { @Override public Health aggregate(Map<String, Health> healths) { Health.Builder builder = Health.up(); for (Map.Entry<String, Health> entry : healths.entrySet()) { String serviceName = entry.getKey(); Health health = entry.getValue(); IntegrationBridgeServiceInfo service = (IntegrationBridgeServiceInfo) health.getDetails().get(serviceName); if (service != null) { builder = builder.withDetail(serviceName, service); } if (isServiceDown(health.getStatus(), service)) { builder = builder.down(); } } return builder.build(); }  @Override Health aggregate(Map<String, Health> healths);  }