@Test public void shouldPopulateOrderLinesAndEscapeThemForXML() throws WorldpayConfigurationException { when(cartModelMock.getTotalTax()).thenReturn(14.16); when(cartModelMock.getEntries()).thenReturn(singletonList(cartEntryModelMock)); when(cartModelMock.getCurrency().getDigits()).thenReturn(2); when(cartEntryModelMock.getOrder().getCurrency().getDigits()).thenReturn(2); when(cartEntryModelMock.getEntryNumber()).thenReturn(1); when(cartEntryModelMock.getProduct().getName()).thenReturn("productáéÑÑÑName"); when(cartEntryModelMock.getQuantity()).thenReturn(1L); when(cartEntryModelMock.getProduct().getUnit().getName()).thenReturn("Stück"); when(cartEntryModelMock.getBasePrice()).thenReturn(84.96); when(cartEntryModelMock.getTotalPrice()).thenReturn(84.96); when(cartEntryModelMock.getTaxValues()).thenReturn(singletonList(new TaxValue(UK_VAT_FULL, 20, false, 14.16D, "GBP"))); when(cartEntryModelMock.getDiscountValues()).thenReturn(singletonList(new DiscountValue("dv", 0D, false, "GBP"))); final OrderLines result = testObj.createOrderLines(cartModelMock); assertThat(result.getTermsURL()).isEqualToIgnoringCase(TERMS_URL); assertThat(result.getLineItems()).hasSize(1); assertThat(result.getOrderTaxAmount()).isEqualToIgnoringCase("1416"); final LineItem lineItem = result.getLineItems().get(0); assertThat(lineItem.getLineItemReference().getValue()).isEqualToIgnoringCase("1"); assertThat(lineItem.getName()).isEqualToIgnoringCase(StringEscapeUtils.escapeXml("productáéÑÑÑName")); assertThat(lineItem.getQuantityUnit()).isEqualToIgnoringCase(StringEscapeUtils.escapeXml("Stück")); assertThat(lineItem.getQuantity()).isEqualToIgnoringCase("1"); assertThat(lineItem.getTaxRate()).isEqualToIgnoringCase(EXPECTED_2000); assertThat(lineItem.getTotalTaxAmount()).isEqualToIgnoringCase("1416"); assertThat(lineItem.getTotalDiscountAmount()).isEqualToIgnoringCase("0"); assertThat(lineItem.getLineItemType()).isEqualTo(LineItem.LINE_ITEM_TYPE.PHYSICAL); }
@Override public OrderLines createOrderLines(CartModel cartModel) throws WorldpayConfigurationException { final Integer digits = cartModel.getCurrency().getDigits(); final String orderTaxAmount = convertDoubleToStringFormat(digits, cartModel.getTotalTax()); final String termsURL = worldpayUrlService.getFullTermsUrl(); final List<LineItem> lineItems = cartModel.getEntries().stream().map(this::createLineItem).collect(toList()); if (cartModel.getDeliveryCost() > 0) { addShippingFeeLineItem(cartModel, digits, lineItems); } if (cartModel.getGlobalDiscountValues().stream().anyMatch(DiscountValue::isAbsolute)) { lineItems.add(createDiscountLineItem(cartModel, digits)); } final OrderLines orderLines = new OrderLines(orderTaxAmount, termsURL, lineItems); if (orderLines.getLineItems().size() > 1) { verifySweepPennies(cartModel, orderLines); } return orderLines; }
DefaultWorldpayKlarnaStrategy implements WorldpayKlarnaStrategy { @Override public OrderLines createOrderLines(CartModel cartModel) throws WorldpayConfigurationException { final Integer digits = cartModel.getCurrency().getDigits(); final String orderTaxAmount = convertDoubleToStringFormat(digits, cartModel.getTotalTax()); final String termsURL = worldpayUrlService.getFullTermsUrl(); final List<LineItem> lineItems = cartModel.getEntries().stream().map(this::createLineItem).collect(toList()); if (cartModel.getDeliveryCost() > 0) { addShippingFeeLineItem(cartModel, digits, lineItems); } if (cartModel.getGlobalDiscountValues().stream().anyMatch(DiscountValue::isAbsolute)) { lineItems.add(createDiscountLineItem(cartModel, digits)); } final OrderLines orderLines = new OrderLines(orderTaxAmount, termsURL, lineItems); if (orderLines.getLineItems().size() > 1) { verifySweepPennies(cartModel, orderLines); } return orderLines; } }
DefaultWorldpayKlarnaStrategy implements WorldpayKlarnaStrategy { @Override public OrderLines createOrderLines(CartModel cartModel) throws WorldpayConfigurationException { final Integer digits = cartModel.getCurrency().getDigits(); final String orderTaxAmount = convertDoubleToStringFormat(digits, cartModel.getTotalTax()); final String termsURL = worldpayUrlService.getFullTermsUrl(); final List<LineItem> lineItems = cartModel.getEntries().stream().map(this::createLineItem).collect(toList()); if (cartModel.getDeliveryCost() > 0) { addShippingFeeLineItem(cartModel, digits, lineItems); } if (cartModel.getGlobalDiscountValues().stream().anyMatch(DiscountValue::isAbsolute)) { lineItems.add(createDiscountLineItem(cartModel, digits)); } final OrderLines orderLines = new OrderLines(orderTaxAmount, termsURL, lineItems); if (orderLines.getLineItems().size() > 1) { verifySweepPennies(cartModel, orderLines); } return orderLines; } DefaultWorldpayKlarnaStrategy(CommonI18NService commonI18NService, WorldpayUrlService worldpayUrlService); }
DefaultWorldpayKlarnaStrategy implements WorldpayKlarnaStrategy { @Override public OrderLines createOrderLines(CartModel cartModel) throws WorldpayConfigurationException { final Integer digits = cartModel.getCurrency().getDigits(); final String orderTaxAmount = convertDoubleToStringFormat(digits, cartModel.getTotalTax()); final String termsURL = worldpayUrlService.getFullTermsUrl(); final List<LineItem> lineItems = cartModel.getEntries().stream().map(this::createLineItem).collect(toList()); if (cartModel.getDeliveryCost() > 0) { addShippingFeeLineItem(cartModel, digits, lineItems); } if (cartModel.getGlobalDiscountValues().stream().anyMatch(DiscountValue::isAbsolute)) { lineItems.add(createDiscountLineItem(cartModel, digits)); } final OrderLines orderLines = new OrderLines(orderTaxAmount, termsURL, lineItems); if (orderLines.getLineItems().size() > 1) { verifySweepPennies(cartModel, orderLines); } return orderLines; } DefaultWorldpayKlarnaStrategy(CommonI18NService commonI18NService, WorldpayUrlService worldpayUrlService); @Override OrderLines createOrderLines(CartModel cartModel); }
DefaultWorldpayKlarnaStrategy implements WorldpayKlarnaStrategy { @Override public OrderLines createOrderLines(CartModel cartModel) throws WorldpayConfigurationException { final Integer digits = cartModel.getCurrency().getDigits(); final String orderTaxAmount = convertDoubleToStringFormat(digits, cartModel.getTotalTax()); final String termsURL = worldpayUrlService.getFullTermsUrl(); final List<LineItem> lineItems = cartModel.getEntries().stream().map(this::createLineItem).collect(toList()); if (cartModel.getDeliveryCost() > 0) { addShippingFeeLineItem(cartModel, digits, lineItems); } if (cartModel.getGlobalDiscountValues().stream().anyMatch(DiscountValue::isAbsolute)) { lineItems.add(createDiscountLineItem(cartModel, digits)); } final OrderLines orderLines = new OrderLines(orderTaxAmount, termsURL, lineItems); if (orderLines.getLineItems().size() > 1) { verifySweepPennies(cartModel, orderLines); } return orderLines; } DefaultWorldpayKlarnaStrategy(CommonI18NService commonI18NService, WorldpayUrlService worldpayUrlService); @Override OrderLines createOrderLines(CartModel cartModel);  }