### Question:
CmsPsuConfirmationOfFundsServiceInternal implements CmsPsuConfirmationOfFundsService { @Override @Transactional public boolean updateConsentStatus(@NotNull String consentId, @NotNull ConsentStatus status, @NotNull String instanceId) { Optional<ConsentEntity> consentEntityOptional = getActualConsent(consentId, instanceId); if (consentEntityOptional.isEmpty()) { log.info("Consent ID: [{}], Instance ID: [{}]. Update of consent status failed, because consent either has finalised status or not found", consentId, instanceId); return false; } ConsentEntity consentEntity = consentEntityOptional.get(); consentEntity.setConsentStatus(status); return true; }  @Override @Transactional boolean updateAuthorisationStatus(@NotNull PsuIdData psuIdData, @NotNull String consentId,
                                             @NotNull String authorisationId, @NotNull ScaStatus status,
                                             @NotNull String instanceId, AuthenticationDataHolder authenticationDataHolder); @Override @Transactional boolean updatePsuDataInConsent(@NotNull PsuIdData psuIdData, @NotNull String authorisationId, @NotNull String instanceId); @Override @Transactional @NotNull Optional<CmsConfirmationOfFundsConsent> getConsent(@NotNull PsuIdData psuIdData,
                                                                       @NotNull String consentId,
                                                                       @NotNull String instanceId); @Override @Transactional Optional<CmsConfirmationOfFundsResponse> checkRedirectAndGetConsent(String redirectId, String instanceId); @Override @NotNull Optional<CmsPsuConfirmationOfFundsAuthorisation> getAuthorisationByAuthorisationId(@NotNull String authorisationId, @NotNull String instanceId); @Override @Transactional boolean updateConsentStatus(@NotNull String consentId, @NotNull ConsentStatus status, @NotNull String instanceId);  }### Answer:
@Test void updateConsentStatus() { when(confirmationOfFundsConsentSpecification.byConsentIdAndInstanceId(CONSENT_ID, INSTANCE_ID)) .thenReturn((root, criteriaQuery, criteriaBuilder) -> null); when(consentJpaRepository.findOne(any(Specification.class))) .thenReturn(Optional.of(consentEntity)); ConsentStatus consentStatus = ConsentStatus.VALID; boolean result = cmsPsuConfirmationOfFundsServiceInternal.updateConsentStatus(CONSENT_ID, consentStatus, INSTANCE_ID); assertTrue(result); assertEquals(consentStatus, consentEntity.getConsentStatus()); }
@Test void updateConsentStatus_getActualConsent_empty() { when(confirmationOfFundsConsentSpecification.byConsentIdAndInstanceId(CONSENT_ID, INSTANCE_ID)) .thenReturn((root, criteriaQuery, criteriaBuilder) -> null); when(consentJpaRepository.findOne(any(Specification.class))) .thenReturn(Optional.empty()); ConsentStatus consentStatus = ConsentStatus.VALID; boolean result = cmsPsuConfirmationOfFundsServiceInternal.updateConsentStatus(CONSENT_ID, consentStatus, INSTANCE_ID); assertFalse(result); assertNotEquals(consentStatus, consentEntity.getConsentStatus()); }