### Question:
PisCommonPaymentServiceInternalEncrypted implements PisCommonPaymentServiceEncrypted { @Override @Transactional public CmsResponse<CreatePisCommonPaymentResponse> createCommonPayment(PisPaymentInfo request) { CmsResponse<CreatePisCommonPaymentResponse> paymentResponse = pisCommonPaymentService.createCommonPayment(request); if (paymentResponse.hasError()) { return paymentResponse; } CreatePisCommonPaymentResponse payment = paymentResponse.getPayload(); Optional<String> encryptIdOptional = securityDataService.encryptId(payment.getPaymentId()); if (encryptIdOptional.isEmpty()) { log.info("Payment ID: [{}]. Create common payment failed, couldn't encrypt payment id", payment.getPaymentId()); return CmsResponse.<CreatePisCommonPaymentResponse>builder() .error(TECHNICAL_ERROR) .build(); } return CmsResponse.<CreatePisCommonPaymentResponse>builder() .payload(new CreatePisCommonPaymentResponse(encryptIdOptional.get(), payment.getTppNotificationContentPreferred())) .build(); }  @Override @Transactional CmsResponse<CreatePisCommonPaymentResponse> createCommonPayment(PisPaymentInfo request); @Override @Transactional CmsResponse<TransactionStatus> getPisCommonPaymentStatusById(String encryptedPaymentId); @Override @Transactional CmsResponse<PisCommonPaymentResponse> getCommonPaymentById(String encryptedPaymentId); @Override @Transactional CmsResponse<Boolean> updateCommonPaymentStatusById(String encryptedPaymentId, TransactionStatus status); @Override CmsResponse<String> getDecryptedId(String encryptedId); @Override @Transactional CmsResponse<Boolean> updateMultilevelSca(String encryptedPaymentId, boolean multilevelScaRequired); @Override CmsResponse<List<PsuIdData>> getPsuDataListByPaymentId(String encryptedPaymentId);  }### Answer:
@Test void createCommonPayment_success() { PisPaymentInfo request = buildPisPaymentInfoRequest(); CreatePisCommonPaymentResponse expected = buildCreatePisCommonPaymentResponse(ENCRYPTED_PAYMENT_ID); when(securityDataService.encryptId(DECRYPTED_PAYMENT_ID)) .thenReturn(Optional.of(ENCRYPTED_PAYMENT_ID)); when(pisCommonPaymentService.createCommonPayment(buildPisPaymentInfoRequest())) .thenReturn(CmsResponse.<CreatePisCommonPaymentResponse>builder() .payload(buildCreatePisCommonPaymentResponse(DECRYPTED_PAYMENT_ID)) .build()); CmsResponse<CreatePisCommonPaymentResponse> actual = pisCommonPaymentServiceInternalEncrypted.createCommonPayment(request); assertTrue(actual.isSuccessful()); assertEquals(expected, actual.getPayload()); verify(pisCommonPaymentService, times(1)).createCommonPayment(request); }
@Test void createCommonPayment_technicalError() { PisPaymentInfo request = buildPisPaymentInfoRequest(); when(pisCommonPaymentService.createCommonPayment(buildPisPaymentInfoRequest())) .thenReturn(CmsResponse.<CreatePisCommonPaymentResponse>builder() .payload(buildCreatePisCommonPaymentResponse(DECRYPTED_PAYMENT_ID)) .build()); when(securityDataService.encryptId(DECRYPTED_PAYMENT_ID)).thenReturn(Optional.empty()); CmsResponse<CreatePisCommonPaymentResponse> actual = pisCommonPaymentServiceInternalEncrypted.createCommonPayment(request); assertTrue(actual.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, actual.getError()); }