### Question:
Xs2aAuthorisationService { public Optional<CreateAuthorisationResponse> createAuthorisation(CreateAuthorisationRequest request, String parentId, AuthorisationType authorisationType) { CmsResponse<CreateAuthorisationResponse> authorisationResponse = authorisationServiceEncrypted.createAuthorisation(new AuthorisationParentHolder(authorisationType, parentId), request); if (authorisationResponse.hasError()) { return Optional.empty(); } return Optional.ofNullable(authorisationResponse.getPayload()); }  Optional<CreateAuthorisationResponse> createAuthorisation(CreateAuthorisationRequest request, String parentId, AuthorisationType authorisationType); Optional<Authorisation> getAuthorisationById(String authorisationId); void updateScaApproach(String authorisationId, ScaApproach scaApproach); boolean saveAuthenticationMethods(String authorisationId, List<AuthenticationObject> methods); boolean isAuthenticationMethodDecoupled(String authorisationId, String authenticationMethodId); void updateAuthorisationStatus(String authorisationId, ScaStatus scaStatus); Optional<AuthorisationScaApproachResponse> getAuthorisationScaApproach(String authorisationId); Optional<List<String>> getAuthorisationSubResources(String parentId, AuthorisationType authorisationType); CmsResponse<Authorisation> updateAuthorisation(UpdateAuthorisationRequest request, String authorisationId); Optional<ScaStatus> getAuthorisationScaStatus(String authorisationId, String parentId, AuthorisationType authorisationType);  }### Answer:
@Test void createAuthorisation() { CreateAuthorisationRequest request = jsonReader.getObjectFromFile("json/service/mapper/consent/create-authorisation-request.json", CreateAuthorisationRequest.class); CreateAuthorisationResponse response = jsonReader.getObjectFromFile("json/service/mapper/spi_xs2a_mappers/create-pis-authorisation-response.json", CreateAuthorisationResponse.class); when(authorisationServiceEncrypted.createAuthorisation(new AisAuthorisationParentHolder(CONSENT_ID), request)) .thenReturn(CmsResponse.<CreateAuthorisationResponse>builder().payload(response).build()); Optional<CreateAuthorisationResponse> actual = authorisationService.createAuthorisation(request, CONSENT_ID, AuthorisationType.CONSENT); assertTrue(actual.isPresent()); assertEquals(response, actual.get()); }
@Test void createAuthorisation_hasError() { CreateAuthorisationRequest request = jsonReader.getObjectFromFile("json/service/mapper/consent/create-authorisation-request.json", CreateAuthorisationRequest.class); when(authorisationServiceEncrypted.createAuthorisation(new AisAuthorisationParentHolder(CONSENT_ID), request)) .thenReturn(CmsResponse.<CreateAuthorisationResponse>builder().error(CmsError.TECHNICAL_ERROR).build()); Optional<CreateAuthorisationResponse> actual = authorisationService.createAuthorisation(request, CONSENT_ID, AuthorisationType.CONSENT); assertTrue(actual.isEmpty()); }