### Question:
ConsentServiceRemote implements ConsentServiceEncrypted { @Override public CmsResponse<ConsentStatus> getConsentStatusById(String consentId) { try { ConsentStatusResponse response = consentRestTemplate.getForEntity(consentRemoteUrls.getConsentStatusById(), ConsentStatusResponse.class, consentId).getBody(); if (response != null) { return CmsResponse.<ConsentStatus>builder() .payload(response.getConsentStatus()) .build(); } log.info("Couldn't get consent status by consent ID {}", consentId); } catch (CmsRestException cmsRestException) { log.info("Couldn't get consent status by consent ID {}, HTTP response status: {}", consentId, cmsRestException.getHttpStatus()); } return CmsResponse.<ConsentStatus>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 getConsentStatusById() { when(consentRemoteUrls.getConsentStatusById()).thenReturn(URL); ConsentStatus consentStatus = ConsentStatus.RECEIVED; when(consentRestTemplate.getForEntity(URL, ConsentStatusResponse.class, CONSENT_ID)) .thenReturn(ResponseEntity.ok(new ConsentStatusResponse(consentStatus))); CmsResponse<ConsentStatus> actualResponse = consentServiceRemote.getConsentStatusById(CONSENT_ID); assertTrue(actualResponse.isSuccessful()); assertEquals(consentStatus, actualResponse.getPayload()); }
@Test void getConsentStatusById_nullResponse() { when(consentRemoteUrls.getConsentStatusById()).thenReturn(URL); ConsentStatus consentStatus = ConsentStatus.RECEIVED; when(consentRestTemplate.getForEntity(URL, ConsentStatusResponse.class, CONSENT_ID)) .thenReturn(ResponseEntity.ok().build()); CmsResponse<ConsentStatus> actualResponse = consentServiceRemote.getConsentStatusById(CONSENT_ID); assertTrue(actualResponse.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, actualResponse.getError()); }
@Test void getConsentStatusById_cmsRestException() { when(consentRemoteUrls.getConsentStatusById()).thenReturn(URL); when(consentRestTemplate.getForEntity(URL, ConsentStatusResponse.class, CONSENT_ID)) .thenThrow(CmsRestException.class); CmsResponse<ConsentStatus> actualResponse = consentServiceRemote.getConsentStatusById(CONSENT_ID); assertTrue(actualResponse.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, actualResponse.getError()); }