### Question:
ConsentServiceInternal implements ConsentService { @Override @Transactional(rollbackFor = WrongChecksumException.class) public CmsResponse<Boolean> updateConsentStatusById(String consentId, ConsentStatus status) throws WrongChecksumException { Optional<ConsentEntity> consentOptional = getActualAisConsent(consentId); if (consentOptional.isPresent()) { ConsentEntity consent = consentOptional.get(); boolean result = setStatusAndSaveConsent(consent, status); return CmsResponse.<Boolean>builder() .payload(result) .build(); } log.info("Consent ID [{}]. Update consent status by ID failed, because consent not found", consentId); return CmsResponse.<Boolean>builder() .error(LOGICAL_ERROR) .build(); }  @Override @Transactional(rollbackFor = WrongChecksumException.class) CmsResponse<CmsCreateConsentResponse> createConsent(CmsConsent cmsConsent); @Override @Transactional CmsResponse<ConsentStatus> getConsentStatusById(String consentId); @Override @Transactional(rollbackFor = WrongChecksumException.class) CmsResponse<Boolean> updateConsentStatusById(String consentId, ConsentStatus status); @Override @Transactional CmsResponse<CmsConsent> getConsentById(String consentId); @Override @Transactional CmsResponse<Boolean> findAndTerminateOldConsentsByNewConsentId(String newConsentId); @Override CmsResponse<List<PsuIdData>> getPsuDataByConsentId(String consentId); @Override @Transactional(rollbackFor = WrongChecksumException.class) CmsResponse<Boolean> updateMultilevelScaRequired(String consentId, boolean multilevelScaRequired);  }### Answer:
@Test void updateConsentStatusById_UpdateFinalisedStatus_Fail() throws WrongChecksumException { ConsentEntity finalisedConsent = buildFinalisedConsent(); when(consentJpaRepository.findByExternalId(FINALISED_CONSENT_ID)) .thenReturn(Optional.of(finalisedConsent)); CmsResponse<Boolean> actual = consentServiceInternal.updateConsentStatusById(FINALISED_CONSENT_ID, ConsentStatus.EXPIRED); assertLogicalError(actual); }
@Test void updateConsentStatusById_noActualConsent_shouldReturnFalse() throws WrongChecksumException { ConsentEntity nonFinalisedConsent = buildFinalisedConsent(); nonFinalisedConsent.setConsentStatus(ConsentStatus.PARTIALLY_AUTHORISED); when(consentJpaRepository.findByExternalId(FINALISED_CONSENT_ID)) .thenReturn(Optional.of(nonFinalisedConsent)); CmsResponse<Boolean> result = consentServiceInternal.updateConsentStatusById(FINALISED_CONSENT_ID, ConsentStatus.EXPIRED); assertTrue(result.isSuccessful()); assertEquals(Boolean.FALSE, result.getPayload()); }