@Transactional
public void addAnotherItemToOrder() throws AddToCartException {
// In the database, some Skus are inactive and some are active. This ensures that we pull back an active one
// to test a successful cart add
Sku sku = getFirstActiveSku();
Order order = orderService.findOrderById(orderId);
assert order != null;
assert sku.getId() != null;
orderService.setAutomaticallyMergeLikeItems(true);
OrderItemRequestDTO itemRequest = new OrderItemRequestDTO();
itemRequest.setQuantity(1);
itemRequest.setSkuId(sku.getId());
// Note that we are not incrementing the numOrderItems count because it should have gotten merged
order = orderService.addItem(orderId, itemRequest, true);
DiscreteOrderItem item = (DiscreteOrderItem) orderService.findLastMatchingItem(order, sku.getId(), null);
assert item.getSku() != null;
assert item.getSku().equals(sku);
assert item.getQuantity() == 2; // item-was merged with prior item.
order = orderService.findOrderById(orderId);
assert(order.getOrderItems().size()==1);
assert(order.getOrderItems().get(0).getQuantity()==2);
assert order.getFulfillmentGroups().size() == 1;
FulfillmentGroup fg = order.getFulfillmentGroups().get(0);
assert fg.getFulfillmentGroupItems().size() == 1;
FulfillmentGroupItem fgItem = fg.getFulfillmentGroupItems().get(0);
assert fgItem.getOrderItem().equals(item);
assert fgItem.getQuantity() == item.getQuantity();