### Question:
SessionService { public SessionId getSessionIfItExists(SessionId sessionId) { if (sessionRepository.sessionExists(sessionId)) { return sessionId; } throw new SessionNotFoundException(sessionId); } @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 getSession_ReturnSessionIdWhenSessionExists() { SessionId sessionId = createNewSessionId(); when(sessionRepository.sessionExists(sessionId)).thenReturn(true); assertThat(service.getSessionIfItExists(sessionId)).isEqualTo(sessionId); }
@Test(expected = SessionNotFoundException.class) public void getSession_ThrowsExceptionWhenSessionDoesNotExists() { SessionId sessionId = createNewSessionId(); when(sessionRepository.sessionExists(sessionId)).thenReturn(false); assertThat(service.getSessionIfItExists(sessionId)).isEqualTo(sessionId); }