DefaultWorldpayCaptureCommand extends WorldpayCommand implements CaptureCommand { @Override public CaptureResult perform(final CaptureRequest request) { final String merchantCode = request.getRequestToken(); final String orderCode = request.getRequestId(); final BigDecimal amount = request.getTotalAmount(); final Currency currency = request.getCurrency(); try { final CaptureServiceRequest captureRequest = buildCaptureServiceRequest(orderCode, amount, currency, getShippingInfosFromOrder(orderCode)); return capture(captureRequest); } catch (final WorldpayException e) { LOG.error(MessageFormat.format("Error during capture of payment with ordercode [{0}] to merchant [{1}]", orderCode, merchantCode), e); return createErrorCaptureResult(); } } DefaultWorldpayCaptureCommand(final Converter<CaptureServiceResponse, CaptureResult> captureServiceResponseConverter, final WorldpayHybrisOrderService worldpayHybrisOrderService, final WorldpayMerchantInfoService worldpayMerchantInfoService, final WorldpayPaymentTransactionService worldpayPaymentTransactionService, final WorldpayOrderService worldpayOrderService, final WorldpayServiceGateway worldpayServiceGateway); @Override CaptureResult perform(final CaptureRequest request);  }
@Test public void perform_WhenCaptureRequestIsReceived_ShouldCreateAndSendCaptureCommandToWorldpay() { testObj.perform(captureRequestMock); verify(captureResponseConverterMock).convert(captureResponseMock); verify(captureResultMock).setRequestToken(MERCHANT_CODE); }
@Test public void perform_WhenCaptureRequestIsReceived_ShouldAddTrackingIdFromOrderConsigments() { testObj.perform(captureRequestMock); verify(worldpayHybrisOrderServiceMock).findOrderByWorldpayOrderCode(WORLDPAY_ORDER_CODE); verify(orderModelMock).getConsignments(); verify(consigment1Mock).getTrackingID(); verify(consigment2Mock).getTrackingID(); }