### Question:
ConsentServiceRemote implements ConsentServiceEncrypted { @Override public CmsResponse<CmsConsent> getConsentById(String consentId) { try { ResponseEntity<CmsConsent> accountConsent = consentRestTemplate.getForEntity(consentRemoteUrls.getConsentById(), CmsConsent.class, consentId); return CmsResponse.<CmsConsent>builder() .payload(accountConsent.getBody()) .build(); } catch (CmsRestException cmsRestException) { log.info("Couldn't get consent by consent ID {}, HTTP response status: {}", consentId, cmsRestException.getHttpStatus()); } return CmsResponse.<CmsConsent>builder() .error(TECHNICAL_ERROR) .build(); }  @Override CmsResponse<CmsCreateConsentResponse> createConsent(CmsConsent cmsConsent); @Override CmsResponse<ConsentStatus> getConsentStatusById(String consentId); @Override CmsResponse<Boolean> updateConsentStatusById(String consentId, ConsentStatus status); @Override CmsResponse<CmsConsent> getConsentById(String consentId); @Override CmsResponse<Boolean> findAndTerminateOldConsentsByNewConsentId(String newConsentId); @Override CmsResponse<List<PsuIdData>> getPsuDataByConsentId(String consentId); @Override CmsResponse<Boolean> updateMultilevelScaRequired(String encryptedConsentId, boolean multilevelScaRequired);  }### Answer:
@Test void getConsentById() { when(consentRemoteUrls.getConsentById()).thenReturn(URL); CmsConsent cmsConsent = new CmsConsent(); when(consentRestTemplate.getForEntity(URL, CmsConsent.class, CONSENT_ID)) .thenReturn(ResponseEntity.ok(cmsConsent)); CmsResponse<CmsConsent> actualResponse = consentServiceRemote.getConsentById(CONSENT_ID); assertTrue(actualResponse.isSuccessful()); assertEquals(cmsConsent, actualResponse.getPayload()); }
@Test void getConsentById_noContent() { when(consentRemoteUrls.getConsentById()).thenReturn(URL); when(consentRestTemplate.getForEntity(URL, CmsConsent.class, CONSENT_ID)) .thenReturn(ResponseEntity.noContent().build()); CmsResponse<CmsConsent> actualResponse = consentServiceRemote.getConsentById(CONSENT_ID); assertTrue(actualResponse.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, actualResponse.getError()); }
@Test void getConsentById_cmsRestException() { when(consentRemoteUrls.getConsentById()).thenReturn(URL); when(consentRestTemplate.getForEntity(URL, CmsConsent.class, CONSENT_ID)) .thenThrow(CmsRestException.class); CmsResponse<CmsConsent> actualResponse = consentServiceRemote.getConsentById(CONSENT_ID); assertTrue(actualResponse.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, actualResponse.getError()); }