### Question:
AuthorisationServiceInternal implements AuthorisationService { @Transactional(readOnly = true) @Override public CmsResponse<Authorisation> getAuthorisationById(String authorisationId) { Optional<AuthorisationEntity> authorisationOptional = getAuthorisation(authorisationId); if (authorisationOptional.isEmpty()) { log.info("Authorisation ID: [{}]. Get authorisation has failed, because authorisation could not found", authorisationId); return CmsResponse.<Authorisation>builder() .error(LOGICAL_ERROR) .build(); } AuthorisationEntity authorisation = authorisationOptional.get(); return CmsResponse.<Authorisation>builder() .payload(authorisationMapper.mapToAuthorisation(authorisation)) .build(); }  @Transactional @Override CmsResponse<CreateAuthorisationResponse> createAuthorisation(AuthorisationParentHolder parentHolder, CreateAuthorisationRequest request); @Transactional(readOnly = true) @Override CmsResponse<Authorisation> getAuthorisationById(String authorisationId); @Transactional @Override CmsResponse<Authorisation> updateAuthorisation(String authorisationId, UpdateAuthorisationRequest request); @Transactional @Override CmsResponse<Boolean> updateAuthorisationStatus(String authorisationId, ScaStatus scaStatus); @Transactional @Override CmsResponse<List<String>> getAuthorisationsByParentId(AuthorisationParentHolder parentHolder); @Transactional @Override CmsResponse<ScaStatus> getAuthorisationScaStatus(String authorisationId, AuthorisationParentHolder parentHolder); @Transactional(readOnly = true) @Override CmsResponse<Boolean> isAuthenticationMethodDecoupled(String authorisationId, String authenticationMethodId); @Transactional @Override CmsResponse<Boolean> saveAuthenticationMethods(String authorisationId, List<CmsScaMethod> methods); @Transactional @Override CmsResponse<Boolean> updateScaApproach(String authorisationId, ScaApproach scaApproach); @Transactional(readOnly = true) @Override CmsResponse<AuthorisationScaApproachResponse> getAuthorisationScaApproach(String authorisationId);  }### Answer:
@Test void getAuthorisationById() { AuthorisationEntity authorisationEntity = jsonReader.getObjectFromFile("json/service/authorisation-entity.json", AuthorisationEntity.class); when(authorisationRepository.findByExternalId(AUTHORISATION_ID)).thenReturn(Optional.of(authorisationEntity)); Authorisation mappedAuthorisation = jsonReader.getObjectFromFile("json/service/authorisation.json", Authorisation.class); when(authorisationMapper.mapToAuthorisation(authorisationEntity)).thenReturn(mappedAuthorisation); CmsResponse<Authorisation> actualResponse = authorisationServiceInternal.getAuthorisationById(AUTHORISATION_ID); assertTrue(actualResponse.isSuccessful()); assertEquals(mappedAuthorisation, actualResponse.getPayload()); }
@Test void getAuthorisationById_wrongId() { when(authorisationRepository.findByExternalId(WRONG_AUTHORISATION_ID)).thenReturn(Optional.empty()); CmsResponse<Authorisation> actualResponse = authorisationServiceInternal.getAuthorisationById(WRONG_AUTHORISATION_ID); assertTrue(actualResponse.hasError()); assertEquals(CmsError.LOGICAL_ERROR, actualResponse.getError()); }