### Question:
AccountServiceInternalEncrypted implements AccountServiceEncrypted { @Override public boolean saveNumberOfTransactions(String encryptedConsentId, String resourceId, int numberOfTransactions) { Optional<String> optionalId = securityDataService.decryptId(encryptedConsentId); if (optionalId.isPresent()) { return accountService.saveNumberOfTransactions(optionalId.get(), resourceId, numberOfTransactions); } else { log.info("Encrypted Consent ID: [{}]. Save number of transactions failed, couldn't decrypt consent ID", encryptedConsentId); return false; } }  @Override boolean saveNumberOfTransactions(String encryptedConsentId, String resourceId, int numberOfTransactions);  }### Answer:
@Test void saveNumberOfTransactions_shouldFail() { when(securityDataService.decryptId(ENCRYPTED_CONSENT_ID)).thenReturn(Optional.empty()); boolean result = accountServiceInternalEncrypted.saveNumberOfTransactions(ENCRYPTED_CONSENT_ID, RESOURCE_ID, 10); assertFalse(result); verify(accountService, never()).saveNumberOfTransactions(CONSENT_ID, RESOURCE_ID, 10); }
@Test void saveNumberOfTransactions_success() { when(securityDataService.decryptId(ENCRYPTED_CONSENT_ID)).thenReturn(Optional.of(CONSENT_ID)); when(accountService.saveNumberOfTransactions(CONSENT_ID, RESOURCE_ID, 10)).thenReturn(Boolean.TRUE); boolean result = accountServiceInternalEncrypted.saveNumberOfTransactions(ENCRYPTED_CONSENT_ID, RESOURCE_ID, 10); assertTrue(result); verify(accountService, times(1)).saveNumberOfTransactions(CONSENT_ID, RESOURCE_ID, 10); }