### Question:
SessionService { public AuthnRequestFromHubContainerDto getIdpAuthnRequest(SessionId sessionId) { getSessionIfItExists(sessionId); final AuthnRequestFromHub request = authnRequestHandler.getIdaAuthnRequestFromHub(sessionId); final IdaAuthnRequestFromHubDto authnRequestFromHub = new IdaAuthnRequestFromHubDto( request.getId(), request.getForceAuthentication(), request.getSessionExpiryTimestamp(), request.getRecipientEntityId(), request.getLevelsOfAssurance(), request.getUseExactComparisonType(), request.getOverriddenSsoUrl()); boolean countryIdentityProvider = sessionRepository.isSessionInState(sessionId, EidasCountrySelectedState.class); final SamlRequestDto samlRequest; if (countryIdentityProvider) { samlRequest = samlEngineProxy.generateCountryAuthnRequestFromHub(authnRequestFromHub); EidasConnectorMetrics.increment( request.getRecipientEntityId(), EidasConnectorMetrics.Direction.request, EidasConnectorMetrics.Status.ok); } else { samlRequest = samlEngineProxy.generateIdpAuthnRequestFromHub(authnRequestFromHub); } return new AuthnRequestFromHubContainerDto(samlRequest.getSamlRequest(), samlRequest.getSsoUri(), request.getRegistering()); } @Inject  SessionService(SamlEngineProxy samlEngineProxy,
                          TransactionsConfigProxy configProxy,
                          AuthnRequestFromTransactionHandler authnRequestHandler,
                          SessionRepository sessionRepository); SessionId create(final SamlAuthnRequestContainerDto requestDto); SessionId getSessionIfItExists(SessionId sessionId); Optional<LevelOfAssurance> getLevelOfAssurance(SessionId sessionId); AuthnRequestFromHubContainerDto getIdpAuthnRequest(SessionId sessionId); AuthnResponseFromHubContainerDto getRpAuthnResponse(SessionId sessionId); AuthnResponseFromHubContainerDto getRpErrorResponse(SessionId sessionId);  }### Answer:
@Test public void shouldGetIdpAuthnRequest() { SessionId sessionId = createNewSessionId(); when(sessionRepository.sessionExists(sessionId)).thenReturn(true); AuthnRequestFromHub authnRequestFromHub = anAuthnRequestFromHub().build(); when(authnRequestHandler.getIdaAuthnRequestFromHub(sessionId)).thenReturn(authnRequestFromHub); URI ssoUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build(); SamlRequestDto samlRequest = new SamlRequestDto("samlRequest", ssoUri); when(samlEngineProxy.generateIdpAuthnRequestFromHub(any(IdaAuthnRequestFromHubDto.class))).thenReturn(samlRequest); AuthnRequestFromHubContainerDto idpAuthnRequest = service.getIdpAuthnRequest(sessionId); AuthnRequestFromHubContainerDto expected = new AuthnRequestFromHubContainerDto(samlRequest.getSamlRequest(), ssoUri, authnRequestFromHub.getRegistering()); assertThat(idpAuthnRequest).isEqualToComparingFieldByField(expected); }