@Test public void notificationShouldNotBeMarkedAsDefectiveWhenTokenReplyDoesNotContainAuthenticatedShopperIdAsOrderWasMadeUsingAMerchantToken() throws WorldpayConfigurationException { when(worldpayPaymentTransactionServiceMock.isPreviousTransactionCompleted(WORLDPAY_ORDER_CODE, AUTHORIZATION, orderModelMock)).thenReturn(Boolean.TRUE); when(orderModificationSerialiserMock.deserialise(orderModificationModelMock.getOrderNotificationMessage())).thenReturn(orderNotificationMessageMock); when(orderNotificationMessageMock.getTokenReply()).thenReturn(tokenReplyMock); when(tokenReplyMock.getAuthenticatedShopperID()).thenReturn(null); testObj.processOrderModificationMessages(AUTHORIZATION); verify(orderNotificationServiceMock).processOrderNotificationMessage(any(OrderNotificationMessage.class)); verify(businessProcessServiceMock).triggerEvent(endsWith(AUTHORIZATION.getCode())); verify(worldpayOrderNotificationHandlerMock).setNonDefectiveAndProcessed(orderModificationModelMock); }
@Override public boolean processOrderModificationMessages(final PaymentTransactionType paymentTransactionType) { boolean success = true; final List<WorldpayOrderModificationModel> orderModificationsByType = orderModificationDao.findUnprocessedOrderModificationsByType(paymentTransactionType); for (final WorldpayOrderModificationModel orderModificationModel : orderModificationsByType) { final String worldpayOrderCode = orderModificationModel.getWorldpayOrderCode(); if (REFUSED.equals(paymentTransactionType)) { LOG.info(format("Marking order modification with [{0}] transaction for refused worldpayOrder [{1}] as processed", paymentTransactionType, worldpayOrderCode)); worldpayOrderNotificationHandler.setNonDefectiveAndProcessed(orderModificationModel); } else { success = precessOrderModificationsMessagesNotRefused(paymentTransactionType, orderModificationModel, worldpayOrderCode); } } return success; }
DefaultWorldpayOrderModificationProcessStrategy implements WorldpayOrderModificationProcessStrategy { @Override public boolean processOrderModificationMessages(final PaymentTransactionType paymentTransactionType) { boolean success = true; final List<WorldpayOrderModificationModel> orderModificationsByType = orderModificationDao.findUnprocessedOrderModificationsByType(paymentTransactionType); for (final WorldpayOrderModificationModel orderModificationModel : orderModificationsByType) { final String worldpayOrderCode = orderModificationModel.getWorldpayOrderCode(); if (REFUSED.equals(paymentTransactionType)) { LOG.info(format("Marking order modification with [{0}] transaction for refused worldpayOrder [{1}] as processed", paymentTransactionType, worldpayOrderCode)); worldpayOrderNotificationHandler.setNonDefectiveAndProcessed(orderModificationModel); } else { success = precessOrderModificationsMessagesNotRefused(paymentTransactionType, orderModificationModel, worldpayOrderCode); } } return success; } }
DefaultWorldpayOrderModificationProcessStrategy implements WorldpayOrderModificationProcessStrategy { @Override public boolean processOrderModificationMessages(final PaymentTransactionType paymentTransactionType) { boolean success = true; final List<WorldpayOrderModificationModel> orderModificationsByType = orderModificationDao.findUnprocessedOrderModificationsByType(paymentTransactionType); for (final WorldpayOrderModificationModel orderModificationModel : orderModificationsByType) { final String worldpayOrderCode = orderModificationModel.getWorldpayOrderCode(); if (REFUSED.equals(paymentTransactionType)) { LOG.info(format("Marking order modification with [{0}] transaction for refused worldpayOrder [{1}] as processed", paymentTransactionType, worldpayOrderCode)); worldpayOrderNotificationHandler.setNonDefectiveAndProcessed(orderModificationModel); } else { success = precessOrderModificationsMessagesNotRefused(paymentTransactionType, orderModificationModel, worldpayOrderCode); } } return success; }  }
DefaultWorldpayOrderModificationProcessStrategy implements WorldpayOrderModificationProcessStrategy { @Override public boolean processOrderModificationMessages(final PaymentTransactionType paymentTransactionType) { boolean success = true; final List<WorldpayOrderModificationModel> orderModificationsByType = orderModificationDao.findUnprocessedOrderModificationsByType(paymentTransactionType); for (final WorldpayOrderModificationModel orderModificationModel : orderModificationsByType) { final String worldpayOrderCode = orderModificationModel.getWorldpayOrderCode(); if (REFUSED.equals(paymentTransactionType)) { LOG.info(format("Marking order modification with [{0}] transaction for refused worldpayOrder [{1}] as processed", paymentTransactionType, worldpayOrderCode)); worldpayOrderNotificationHandler.setNonDefectiveAndProcessed(orderModificationModel); } else { success = precessOrderModificationsMessagesNotRefused(paymentTransactionType, orderModificationModel, worldpayOrderCode); } } return success; }  @Override boolean processOrderModificationMessages(final PaymentTransactionType paymentTransactionType); @Required void setOrderModificationDao(OrderModificationDao orderModificationDao); @Required void setBusinessProcessService(BusinessProcessService businessProcessService); @Required void setProcessDefinitionDao(ProcessDefinitionDao processDefinitionDao); @Required void setOrderNotificationService(OrderNotificationService orderNotificationService); @Required void setOrderModificationSerialiser(OrderModificationSerialiser orderModificationSerialiser); @Required void setWorldpayPaymentTransactionService(WorldpayPaymentTransactionService worldpayPaymentTransactionService); @Required void setNonTriggeringOrderStatuses(Set<OrderStatus> nonTriggeringOrderStatuses); @Required void setWorldpayAuthenticatedShopperIdStrategy(final WorldpayAuthenticatedShopperIdStrategy worldpayAuthenticatedShopperIdStrategy); @Required void setWorldpayOrderModificationRefundProcessStrategy(final WorldpayOrderModificationRefundProcessStrategy worldpayOrderModificationRefundProcessStrategy); @Required void setWorldpayCartService(final WorldpayCartService worldpayCartService); @Required void setWorldpayOrderNotificationHandler(final WorldpayOrderNotificationHandler worldpayOrderNotificationHandler); @Required void setWorldpayPlaceOrderFromNotificationStrategy(final WorldpayPlaceOrderFromNotificationStrategy worldpayPlaceOrderFromNotificationStrategy); }
DefaultWorldpayOrderModificationProcessStrategy implements WorldpayOrderModificationProcessStrategy { @Override public boolean processOrderModificationMessages(final PaymentTransactionType paymentTransactionType) { boolean success = true; final List<WorldpayOrderModificationModel> orderModificationsByType = orderModificationDao.findUnprocessedOrderModificationsByType(paymentTransactionType); for (final WorldpayOrderModificationModel orderModificationModel : orderModificationsByType) { final String worldpayOrderCode = orderModificationModel.getWorldpayOrderCode(); if (REFUSED.equals(paymentTransactionType)) { LOG.info(format("Marking order modification with [{0}] transaction for refused worldpayOrder [{1}] as processed", paymentTransactionType, worldpayOrderCode)); worldpayOrderNotificationHandler.setNonDefectiveAndProcessed(orderModificationModel); } else { success = precessOrderModificationsMessagesNotRefused(paymentTransactionType, orderModificationModel, worldpayOrderCode); } } return success; }  @Override boolean processOrderModificationMessages(final PaymentTransactionType paymentTransactionType); @Required void setOrderModificationDao(OrderModificationDao orderModificationDao); @Required void setBusinessProcessService(BusinessProcessService businessProcessService); @Required void setProcessDefinitionDao(ProcessDefinitionDao processDefinitionDao); @Required void setOrderNotificationService(OrderNotificationService orderNotificationService); @Required void setOrderModificationSerialiser(OrderModificationSerialiser orderModificationSerialiser); @Required void setWorldpayPaymentTransactionService(WorldpayPaymentTransactionService worldpayPaymentTransactionService); @Required void setNonTriggeringOrderStatuses(Set<OrderStatus> nonTriggeringOrderStatuses); @Required void setWorldpayAuthenticatedShopperIdStrategy(final WorldpayAuthenticatedShopperIdStrategy worldpayAuthenticatedShopperIdStrategy); @Required void setWorldpayOrderModificationRefundProcessStrategy(final WorldpayOrderModificationRefundProcessStrategy worldpayOrderModificationRefundProcessStrategy); @Required void setWorldpayCartService(final WorldpayCartService worldpayCartService); @Required void setWorldpayOrderNotificationHandler(final WorldpayOrderNotificationHandler worldpayOrderNotificationHandler); @Required void setWorldpayPlaceOrderFromNotificationStrategy(final WorldpayPlaceOrderFromNotificationStrategy worldpayPlaceOrderFromNotificationStrategy);  }