### Question:
CmsAuthorisationService implements AuthService { @Override public AuthorisationEntity saveAuthorisation(CreateAuthorisationRequest request, Authorisable authorisationParent) { List<PsuData> psuDataList = authorisationParent.getPsuDataList(); Optional<PsuData> psuDataOptional = cmsPsuService.definePsuDataForAuthorisation(psuDataMapper.mapToPsuData(request.getPsuData(), authorisationParent.getInstanceId()), psuDataList); psuDataOptional.ifPresent(psuData -> authorisationParent.setPsuDataList(cmsPsuService.enrichPsuData(psuData, psuDataList))); authorisationParent.setPsuDataList(psuDataList); CommonAspspProfileSetting commonAspspProfileSetting = aspspProfileService.getAspspSettings(authorisationParent.getInstanceId()).getCommon(); AuthorisationEntity entity = authorisationMapper.prepareAuthorisationEntity(authorisationParent, request, psuDataOptional, getAuthorisationType(), commonAspspProfileSetting.getRedirectUrlExpirationTimeMs(), commonAspspProfileSetting.getAuthorisationExpirationTimeMs()); return authorisationRepository.save(entity); }  @Override List<AuthorisationEntity> getAuthorisationsByParentId(String parentId); @Override Optional<AuthorisationEntity> getAuthorisationById(String authorisationId); @Override AuthorisationEntity saveAuthorisation(CreateAuthorisationRequest request, Authorisable authorisationParent); @Override AuthorisationEntity doUpdateAuthorisation(AuthorisationEntity authorisationEntity, UpdateAuthorisationRequest updateAuthorisationRequest); @Override Authorisable checkAndUpdateOnConfirmationExpiration(Authorisable authorisable); @Override boolean isConfirmationExpired(Authorisable authorisable); @Override Authorisable updateOnConfirmationExpiration(Authorisable authorisable);  }### Answer:
@Test void saveAuthorisation() { PisCommonPaymentData authorisationParent = new PisCommonPaymentData(); authorisationParent.setPsuDataList(Collections.singletonList(PSU_DATA)); CreateAuthorisationRequest request = new CreateAuthorisationRequest(); request.setPsuData(PSU_ID_DATA); when(psuDataMapper.mapToPsuData(request.getPsuData(), DEFAULT_SERVICE_INSTANCE_ID)).thenReturn(PSU_DATA); when(cmsPsuService.definePsuDataForAuthorisation(PSU_DATA, Collections.singletonList(PSU_DATA))) .thenReturn(Optional.of(PSU_DATA)); when(aspspProfileService.getAspspSettings(authorisationParent.getInstanceId())).thenReturn(aspspSettings); when(aspspSettings.getCommon()).thenReturn(commonAspspProfileSetting); when(commonAspspProfileSetting.getRedirectUrlExpirationTimeMs()).thenReturn(100L); when(commonAspspProfileSetting.getAuthorisationExpirationTimeMs()).thenReturn(200L); AuthorisationEntity entity = new AuthorisationEntity(); when(authorisationMapper.prepareAuthorisationEntity(authorisationParent, request, Optional.of(PSU_DATA), AuthorisationType.PIS_CREATION, 100L, 200L)) .thenReturn(entity); service.saveAuthorisation(request, authorisationParent); verify(authorisationRepository, times(1)).save(entity); }