@Test public void shoudReturnFalseWhenRefundReferenceIsNull() throws Exception { when(orderNotificationMessageMock.getPaymentReply().getRefundReference()).thenReturn(null); final boolean result = testObj.processRefundFollowOn(orderModelMock, orderNotificationMessageMock); assertFalse(result); }
@Override public boolean processRefundFollowOn(final OrderModel orderModel, final OrderNotificationMessage notificationMessage) { final String refundReference = notificationMessage.getPaymentReply().getRefundReference(); if (refundReference != null) { final List<ReturnRequestModel> returnRequests = orderModel.getReturnRequests(); if (CollectionUtils.isNotEmpty(returnRequests)) { final Optional<ReturnRequestModel> returnRequest = findMatchingReturnRequest(refundReference, returnRequests); if (returnRequest.isPresent()) { final ReturnRequestModel matchingReturnRequest = returnRequest.get(); matchingReturnRequest.setStatus(PAYMENT_REVERSED); modelService.save(matchingReturnRequest); final Collection<ReturnProcessModel> returnProcesses = matchingReturnRequest.getReturnProcess(); final ReturnProcessModel returnProcessModel = returnProcesses.iterator().next(); triggerOrderProcessEvent(REFUND_FOLLOW_ON, returnProcessModel); return true; } } } else { LOG.warn("Refund reference is null. The refund will never be processed against any of the return requests of the order"); } return false; }
DefaultWorldpayomsOrderModificationRefundProcessStrategy implements WorldpayOrderModificationRefundProcessStrategy { @Override public boolean processRefundFollowOn(final OrderModel orderModel, final OrderNotificationMessage notificationMessage) { final String refundReference = notificationMessage.getPaymentReply().getRefundReference(); if (refundReference != null) { final List<ReturnRequestModel> returnRequests = orderModel.getReturnRequests(); if (CollectionUtils.isNotEmpty(returnRequests)) { final Optional<ReturnRequestModel> returnRequest = findMatchingReturnRequest(refundReference, returnRequests); if (returnRequest.isPresent()) { final ReturnRequestModel matchingReturnRequest = returnRequest.get(); matchingReturnRequest.setStatus(PAYMENT_REVERSED); modelService.save(matchingReturnRequest); final Collection<ReturnProcessModel> returnProcesses = matchingReturnRequest.getReturnProcess(); final ReturnProcessModel returnProcessModel = returnProcesses.iterator().next(); triggerOrderProcessEvent(REFUND_FOLLOW_ON, returnProcessModel); return true; } } } else { LOG.warn("Refund reference is null. The refund will never be processed against any of the return requests of the order"); } return false; } }
DefaultWorldpayomsOrderModificationRefundProcessStrategy implements WorldpayOrderModificationRefundProcessStrategy { @Override public boolean processRefundFollowOn(final OrderModel orderModel, final OrderNotificationMessage notificationMessage) { final String refundReference = notificationMessage.getPaymentReply().getRefundReference(); if (refundReference != null) { final List<ReturnRequestModel> returnRequests = orderModel.getReturnRequests(); if (CollectionUtils.isNotEmpty(returnRequests)) { final Optional<ReturnRequestModel> returnRequest = findMatchingReturnRequest(refundReference, returnRequests); if (returnRequest.isPresent()) { final ReturnRequestModel matchingReturnRequest = returnRequest.get(); matchingReturnRequest.setStatus(PAYMENT_REVERSED); modelService.save(matchingReturnRequest); final Collection<ReturnProcessModel> returnProcesses = matchingReturnRequest.getReturnProcess(); final ReturnProcessModel returnProcessModel = returnProcesses.iterator().next(); triggerOrderProcessEvent(REFUND_FOLLOW_ON, returnProcessModel); return true; } } } else { LOG.warn("Refund reference is null. The refund will never be processed against any of the return requests of the order"); } return false; }  }
DefaultWorldpayomsOrderModificationRefundProcessStrategy implements WorldpayOrderModificationRefundProcessStrategy { @Override public boolean processRefundFollowOn(final OrderModel orderModel, final OrderNotificationMessage notificationMessage) { final String refundReference = notificationMessage.getPaymentReply().getRefundReference(); if (refundReference != null) { final List<ReturnRequestModel> returnRequests = orderModel.getReturnRequests(); if (CollectionUtils.isNotEmpty(returnRequests)) { final Optional<ReturnRequestModel> returnRequest = findMatchingReturnRequest(refundReference, returnRequests); if (returnRequest.isPresent()) { final ReturnRequestModel matchingReturnRequest = returnRequest.get(); matchingReturnRequest.setStatus(PAYMENT_REVERSED); modelService.save(matchingReturnRequest); final Collection<ReturnProcessModel> returnProcesses = matchingReturnRequest.getReturnProcess(); final ReturnProcessModel returnProcessModel = returnProcesses.iterator().next(); triggerOrderProcessEvent(REFUND_FOLLOW_ON, returnProcessModel); return true; } } } else { LOG.warn("Refund reference is null. The refund will never be processed against any of the return requests of the order"); } return false; }  @Override boolean processRefundFollowOn(final OrderModel orderModel, final OrderNotificationMessage notificationMessage); @Required void setBusinessProcessService(final BusinessProcessService businessProcessService); @Required void setModelService(final ModelService modelService); }
DefaultWorldpayomsOrderModificationRefundProcessStrategy implements WorldpayOrderModificationRefundProcessStrategy { @Override public boolean processRefundFollowOn(final OrderModel orderModel, final OrderNotificationMessage notificationMessage) { final String refundReference = notificationMessage.getPaymentReply().getRefundReference(); if (refundReference != null) { final List<ReturnRequestModel> returnRequests = orderModel.getReturnRequests(); if (CollectionUtils.isNotEmpty(returnRequests)) { final Optional<ReturnRequestModel> returnRequest = findMatchingReturnRequest(refundReference, returnRequests); if (returnRequest.isPresent()) { final ReturnRequestModel matchingReturnRequest = returnRequest.get(); matchingReturnRequest.setStatus(PAYMENT_REVERSED); modelService.save(matchingReturnRequest); final Collection<ReturnProcessModel> returnProcesses = matchingReturnRequest.getReturnProcess(); final ReturnProcessModel returnProcessModel = returnProcesses.iterator().next(); triggerOrderProcessEvent(REFUND_FOLLOW_ON, returnProcessModel); return true; } } } else { LOG.warn("Refund reference is null. The refund will never be processed against any of the return requests of the order"); } return false; }  @Override boolean processRefundFollowOn(final OrderModel orderModel, final OrderNotificationMessage notificationMessage); @Required void setBusinessProcessService(final BusinessProcessService businessProcessService); @Required void setModelService(final ModelService modelService);  }