### Question:
AuthorisationServiceInternal implements AuthorisationService { @Transactional @Override public CmsResponse<Boolean> saveAuthenticationMethods(String authorisationId, List<CmsScaMethod> methods) { Optional<AuthorisationEntity> authorisationOptional = getAuthorisation(authorisationId); if (authorisationOptional.isEmpty()) { log.info("Authorisation ID: [{}]. Save authentication methods has failed, because authorisation couldn't be found", authorisationId); return CmsResponse.<Boolean>builder() .payload(false) .build(); } AuthorisationEntity authorisation = authorisationOptional.get(); authorisation.setAvailableScaMethods(scaMethodMapper.mapToScaMethods(methods)); return CmsResponse.<Boolean>builder() .payload(true) .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 saveAuthenticationMethods() { CmsScaMethod cmsScaMethod = new CmsScaMethod(AUTHENTICATION_METHOD_ID, true); ScaMethod scaMethod = new ScaMethod(); scaMethod.setAuthenticationMethodId(AUTHENTICATION_METHOD_ID); scaMethod.setDecoupled(true); AuthorisationEntity authorisationEntity = new AuthorisationEntity(); when(authorisationRepository.findByExternalId(AUTHORISATION_ID)) .thenReturn(Optional.of(authorisationEntity)); when(scaMethodMapper.mapToScaMethods(Collections.singletonList(cmsScaMethod))) .thenReturn(Collections.singletonList(scaMethod)); CmsResponse<Boolean> actualResponse = authorisationServiceInternal.saveAuthenticationMethods(AUTHORISATION_ID, Collections.singletonList(cmsScaMethod)); assertTrue(actualResponse.isSuccessful()); assertTrue(actualResponse.getPayload()); }
@Test void saveAuthenticationMethods_wrongId() { CmsScaMethod cmsScaMethod = new CmsScaMethod(AUTHENTICATION_METHOD_ID, true); when(authorisationRepository.findByExternalId(WRONG_AUTHORISATION_ID)) .thenReturn(Optional.empty()); CmsResponse<Boolean> actualResponse = authorisationServiceInternal.saveAuthenticationMethods(WRONG_AUTHORISATION_ID, Collections.singletonList(cmsScaMethod)); assertTrue(actualResponse.isSuccessful()); assertFalse(actualResponse.getPayload()); }