DefaultRefundedOrderNotificationProcessorStrategy implements OrderNotificationProcessorStrategy { @Override public void processNotificationMessage(final PaymentTransactionModel paymentTransactionModel, final OrderNotificationMessage orderNotificationMessage) { transactionTemplate.execute(transactionStatus -> { setMatchingEntryAsNotPending(paymentTransactionModel, orderNotificationMessage); return null; }); }  @Override void processNotificationMessage(final PaymentTransactionModel paymentTransactionModel, final OrderNotificationMessage orderNotificationMessage); @Required void setModelService(ModelService modelService); @Required void setTransactionTemplate(TransactionOperations transactionTemplate);  }
@Test public void shouldMarkPaymentTransactionEntriesAsNonPendingWhenTheRefundReferenceMatches() { when(orderNotificationMessageMock.getPaymentReply().getRefundReference()).thenReturn(REFUND_REFERENCE); when(paymentTransactionEntryModelMock.getCode()).thenReturn(REFUND_REFERENCE); when(paymentTransactionModelMock.getEntries()).thenReturn(singletonList(paymentTransactionEntryModelMock)); testObj.processNotificationMessage(paymentTransactionModelMock, orderNotificationMessageMock); verify(paymentTransactionEntryModelMock).setPending(Boolean.FALSE); verify(modelServiceMock).save(paymentTransactionEntryModelMock); }
@Test public void shouldNotMarkPaymentTransactionEntriesAsNonPendingWhenTheRefundReferenceDoesNotMatches() { when(orderNotificationMessageMock.getPaymentReply().getRefundReference()).thenReturn(REFUND_REFERENCE); when(paymentTransactionEntryModelMock.getCode()).thenReturn(REFUND_REFERENCE + "_INVALID"); when(paymentTransactionModelMock.getEntries()).thenReturn(singletonList(paymentTransactionEntryModelMock)); testObj.processNotificationMessage(paymentTransactionModelMock, orderNotificationMessageMock); verify(paymentTransactionEntryModelMock, never()).setPending(Boolean.FALSE); verify(modelServiceMock, never()).save(paymentTransactionEntryModelMock); }