use of org.broadleafcommerce.common.money.CurrencyConversionService in project BroadleafCommerce by BroadleafCommerce.
the class CheckoutTest method testCheckout.
@Test(groups = { "checkout" }, dependsOnGroups = { "createCartForCustomer", "testShippingInsert" }, dataProvider = "USCurrency", dataProviderClass = BroadleafCurrencyProvider.class)
@Transactional
public void testCheckout(BroadleafCurrency usCurrency) throws Exception {
HashMap currencyConsiderationContext = new HashMap();
currencyConsiderationContext.put("aa", "bb");
CurrencyConversionContext.setCurrencyConversionContext(currencyConsiderationContext);
CurrencyConversionContext.setCurrencyConversionService(new CurrencyConversionService() {
@Override
public Money convertCurrency(Money source, Currency destinationCurrency, int destinationScale) {
return source;
}
});
String userName = "customer1";
Customer customer = customerService.readCustomerByUsername(userName);
Order order = orderService.createNewCartForCustomer(customer);
usCurrency = currencyService.save(usCurrency);
order.setCurrency(usCurrency);
Address address = buildAddress();
FulfillmentGroup group = buildFulfillmentGroup(order, address);
addSampleItemToOrder(order, group);
order.setTotalShipping(new Money(0D));
addPaymentToOrder(order, address);
// execute pricing for this order
orderService.save(order, true);
CheckoutResponse response = checkoutService.performCheckout(order);
assert (order.getTotal().greaterThan(order.getSubTotal()));
}
Aggregations