### Question:
AuthorisationServiceRemote implements AuthorisationServiceEncrypted { @Override public CmsResponse<Boolean> saveAuthenticationMethods(String authorisationId, List<CmsScaMethod> methods) { try { ResponseEntity<Void> responseEntity = consentRestTemplate.exchange(authorisationRemoteUrls.saveAuthenticationMethods(), HttpMethod.POST, new HttpEntity<>(methods), Void.class, authorisationId); if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT) { return CmsResponse.<Boolean>builder() .payload(true) .build(); } } catch (CmsRestException cmsRestException) { log.warn("Couldn't save authentication methods {} by authorisation ID {}, HTTP response status: {}", methods, authorisationId, cmsRestException.getHttpStatus()); } return CmsResponse.<Boolean>builder() .payload(false) .build(); }  @Override CmsResponse<CreateAuthorisationResponse> createAuthorisation(AuthorisationParentHolder parentHolder, CreateAuthorisationRequest request); @Override CmsResponse<Authorisation> getAuthorisationById(String authorisationId); @Override CmsResponse<Authorisation> updateAuthorisation(String authorisationId, UpdateAuthorisationRequest request); @Override CmsResponse<Boolean> updateAuthorisationStatus(String authorisationId, ScaStatus scaStatus); @Override CmsResponse<List<String>> getAuthorisationsByParentId(AuthorisationParentHolder parentHolder); @Override CmsResponse<ScaStatus> getAuthorisationScaStatus(String authorisationId, AuthorisationParentHolder parentHolder); @Override CmsResponse<Boolean> isAuthenticationMethodDecoupled(String authorisationId, String authenticationMethodId); @Override CmsResponse<Boolean> saveAuthenticationMethods(String authorisationId, List<CmsScaMethod> methods); @Override CmsResponse<Boolean> updateScaApproach(String authorisationId, ScaApproach scaApproach); @Override CmsResponse<AuthorisationScaApproachResponse> getAuthorisationScaApproach(String authorisationId);  }### Answer:
@Test void saveAuthenticationMethods() { when(authorisationRemoteUrls.saveAuthenticationMethods()).thenReturn(URL); List<CmsScaMethod> cmsScaMethods = Collections.singletonList(new CmsScaMethod(AUTHENTICATION_METHOD_ID, true)); HttpEntity<List<CmsScaMethod>> httpEntity = new HttpEntity<>(cmsScaMethods); when(consentRestTemplate.exchange(URL, HttpMethod.POST, httpEntity, Void.class, AUTHORISATION_ID)) .thenReturn(new ResponseEntity<>(HttpStatus.NO_CONTENT)); CmsResponse<Boolean> actualResponse = authorisationServiceRemote.saveAuthenticationMethods(AUTHORISATION_ID, cmsScaMethods); assertTrue(actualResponse.isSuccessful()); assertTrue(actualResponse.getPayload()); }
@Test void saveAuthenticationMethods_wrongStatusCode() { when(authorisationRemoteUrls.saveAuthenticationMethods()).thenReturn(URL); List<CmsScaMethod> cmsScaMethods = Collections.singletonList(new CmsScaMethod(AUTHENTICATION_METHOD_ID, true)); HttpEntity<List<CmsScaMethod>> httpEntity = new HttpEntity<>(cmsScaMethods); when(consentRestTemplate.exchange(URL, HttpMethod.POST, httpEntity, Void.class, AUTHORISATION_ID)) .thenReturn(new ResponseEntity<>(HttpStatus.OK)); CmsResponse<Boolean> actualResponse = authorisationServiceRemote.saveAuthenticationMethods(AUTHORISATION_ID, cmsScaMethods); assertTrue(actualResponse.isSuccessful()); assertFalse(actualResponse.getPayload()); }
@Test void saveAuthenticationMethods_cmsRestException() { when(authorisationRemoteUrls.saveAuthenticationMethods()).thenReturn(URL); List<CmsScaMethod> cmsScaMethods = Collections.singletonList(new CmsScaMethod(AUTHENTICATION_METHOD_ID, true)); HttpEntity<List<CmsScaMethod>> httpEntity = new HttpEntity<>(cmsScaMethods); when(consentRestTemplate.exchange(URL, HttpMethod.POST, httpEntity, Void.class, AUTHORISATION_ID)) .thenThrow(CmsRestException.class); CmsResponse<Boolean> actualResponse = authorisationServiceRemote.saveAuthenticationMethods(AUTHORISATION_ID, cmsScaMethods); assertTrue(actualResponse.isSuccessful()); assertFalse(actualResponse.getPayload()); }