### Question:
EidasSuccessfulMatchStateController extends AbstractSuccessfulMatchStateController<EidasSuccessfulMatchState> { @Override public ResponseFromHub getPreparedResponse() { List<EidasCountryDto> enabledCountries = countriesService.getCountries(state.getSessionId()); if (enabledCountries.stream().noneMatch(country -> country.getEntityId().equals(state.getIdentityProviderEntityId()))) { throw new IdpDisabledException(state.getIdentityProviderEntityId()); } return getResponse(); } EidasSuccessfulMatchStateController(
            EidasSuccessfulMatchState state,
            ResponseFromHubFactory responseFromHubFactory,
            CountriesService countriesService); @Override ResponseFromHub getPreparedResponse();  }### Answer:
@Test(expected = IdpDisabledException.class) public void getPreparedResponse_shouldThrowWhenCountryIsDisabled() { when(countriesService.getCountries(state.getSessionId())) .thenReturn(emptyList()); controller.getPreparedResponse(); }
@Test public void shouldReturnPreparedResponse() { List<EidasCountryDto> enabledIdentityProviders = singletonList(new EidasCountryDto("country-entity-id", "simple-id", true)); ResponseFromHub expectedResponseFromHub = ResponseFromHubBuilder.aResponseFromHubDto().build(); when(countriesService.getCountries(state.getSessionId())) .thenReturn(enabledIdentityProviders); when(responseFromHubFactory.createSuccessResponseFromHub( state.getRequestId(), state.getMatchingServiceAssertion(), state.getRelayState(), state.getRequestIssuerEntityId(), state.getAssertionConsumerServiceUri())) .thenReturn(expectedResponseFromHub); ResponseFromHub result = controller.getPreparedResponse(); assertThat(result).isEqualTo(expectedResponseFromHub); }