CurrentOrderImpl implements CurrentOrder, HasHandlers { @Override public void addItem(final ShoppingCartItem item) { ShoppingCartItem existingItemOfSameType = getItemFromCart(item); if (existingItemOfSameType != null) { existingItemOfSameType.addMore(item.getQuantity()); ShoppingCartQuantityChangeEvent.fire(this, existingItemOfSameType, existingItemOfSameType.getQuantity()); } else { items.add(item); ShoppingCartChangedEvent.fire(item, this); } shoppingCartLocalStorage.update(items); } @Inject  CurrentOrderImpl(
            EventBus eventBus,
            ShoppingCartLocalStorage shoppingCartLocalStorage); @Override void addItem(final ShoppingCartItem item); @Override void removeItem(ShoppingCartItem item); @Override int getSize(); @Override boolean isEmpty(); @Override ContactInfoDto getContactInfo(); @Override void setContactInfo(ContactInfoDto contactInfo); @Override float calculateSubTotal(); @Override float calculateTaxes(); @Override void setShippingMethod(ShippingMethod shippingMethod); @Override ShippingMethod getShippingMethod(); @Override float calculateGrandTotal(); @Override void fireEvent(GwtEvent<?> gwtEvent); @Override List<ShoppingCartItem> getItems();  }
@Test public void addingTheSameKindOfItemWithTheSameBrand_firesCartQuantityUpdatedEvent() { ShoppingCartItem firstItem = createItem(ProductType.PHONE_CASE, 2); ShoppingCartItem secondItem = createItem(ProductType.PHONE_CASE, 4); currentOrder.addItem(firstItem); Mockito.reset(eventBus); currentOrder.addItem(secondItem); ArgumentCaptor<ShoppingCartQuantityChangeEvent> captor = ArgumentCaptor.forClass(ShoppingCartQuantityChangeEvent.class); verify(eventBus).fireEventFromSource(captor.capture(), same(currentOrder)); assertThat(captor.getValue().getExistingItem()).isEqualTo(secondItem); assertThat(captor.getValue().getNewQuantity()).isEqualTo(6); }