### Question:
MatchingServiceHealthCheckHandler { public AggregatedMatchingServicesHealthCheckResult forceCheckAllMSAs() { return handle(true); } @Inject  MatchingServiceHealthCheckHandler(final MatchingServiceConfigProxy matchingServiceConfigProxy,
                                             final MatchingServiceHealthChecker matchingServiceHealthChecker); AggregatedMatchingServicesHealthCheckResult handle(); AggregatedMatchingServicesHealthCheckResult forceCheckAllMSAs();  }### Answer:
@Test public void handle_shouldExecuteHealthCheckForMatchingServiceWithHealthCheckDisabledWhenForced() { MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().withHealthCheckDisabled().build(); when(matchingServiceConfigProxy.getMatchingServices()).thenReturn(singletonList(matchingServiceConfigEntityDataDto)); matchingServiceHealthCheckHandler.forceCheckAllMSAs(); verify(matchingServiceHealthChecker, times(1)) .performHealthCheck(any(MatchingServiceConfigEntityDataDto.class)); }
@Test public void handle_shouldExecuteHealthCheckForMatchingServiceWithHealthCheckDisabledWhenForcedIfOneEnabledAndOneDisabled() { MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDtoHCDisabled = aMatchingServiceConfigEntityDataDto().withHealthCheckDisabled().withEntityId("1").build(); MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDtoHCEnabled = aMatchingServiceConfigEntityDataDto().withHealthCheckEnabled().withEntityId("2").build(); when(matchingServiceConfigProxy.getMatchingServices()).thenReturn(asList(matchingServiceConfigEntityDataDtoHCDisabled, matchingServiceConfigEntityDataDtoHCEnabled)); matchingServiceHealthCheckHandler.forceCheckAllMSAs(); verify(matchingServiceHealthChecker, times(2)) .performHealthCheck(any(MatchingServiceConfigEntityDataDto.class)); }
@Test public void handle_shouldRemoveDuplicatesFromMatchingServiceList() { MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().withHealthCheckDisabled().withTransactionEntityId("1").build(); MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto2 = aMatchingServiceConfigEntityDataDto().withHealthCheckDisabled().withTransactionEntityId("2").build(); when(matchingServiceConfigProxy.getMatchingServices()).thenReturn(asList(matchingServiceConfigEntityDataDto,matchingServiceConfigEntityDataDto2)); matchingServiceHealthCheckHandler.forceCheckAllMSAs(); verify(matchingServiceHealthChecker, times(1)) .performHealthCheck(any(MatchingServiceConfigEntityDataDto.class)); }