### Question:
CountriesService { public void setSelectedCountry(SessionId sessionId, String countryCode) { ensureTransactionSupportsEidas(sessionId); List<EidasCountryDto> supportedCountries = getCountries(sessionId); EidasCountryDto selectedCountry = supportedCountries.stream() .filter(country -> country.getSimpleId().equals(countryCode)) .findFirst() .orElseThrow(() -> new EidasCountryNotSupportedException(sessionId, countryCode)); EidasCountrySelectingStateController eidasCountrySelectingStateController = (EidasCountrySelectingStateController) sessionRepository.getStateController(sessionId, EidasCountrySelectingState.class); eidasCountrySelectingStateController.selectCountry(selectedCountry.getEntityId()); } @Inject  CountriesService(SessionRepository sessionRepository, TransactionsConfigProxy configProxy); List<EidasCountryDto> getCountries(SessionId sessionId); void setSelectedCountry(SessionId sessionId, String countryCode);  }### Answer:
@Test public void shouldSetSelectedCountry() { EidasCountrySelectedStateController mockEidasCountrySelectedStateController = mock(EidasCountrySelectedStateController.class); when(sessionRepository.getStateController(sessionId, EidasCountrySelectingState.class)).thenReturn(mockEidasCountrySelectedStateController); setSystemWideCountries(singletonList(COUNTRY_1)); service.setSelectedCountry(sessionId, COUNTRY_1.getSimpleId()); verify(mockEidasCountrySelectedStateController).selectCountry(COUNTRY_1.getEntityId()); }
@Test(expected = EidasCountryNotSupportedException.class) public void shouldReturnErrorWhenAnInvalidCountryIsSelected() { setSystemWideCountries(singletonList(COUNTRY_1)); service.setSelectedCountry(sessionId, "not-a-valid-country-code"); }
@Test(expected = EidasNotSupportedException.class) public void shouldReturnErrorWhenACountryIsSelectedWithTxnNotSupportingEidas() { when(sessionRepository.getTransactionSupportsEidas(sessionId)).thenReturn(false); service.setSelectedCountry(sessionId, "NL"); }