CartItemPresenter extends PresenterWidget<CartItemPresenter.MyView> implements CartItemUiHandlers, ShoppingCartQuantityUpdatedEventHandler { @Override public void onQuantityChangedInView(int quantity) { if (quantity == 0) { delete(); } else { item.setQuantity(quantity); ShoppingCartQuantityChangeEvent.fire(this, item, quantity); } } @Inject  CartItemPresenter(
            EventBus eventBus,
            MyView view,
            CurrentOrder currentOrder,
            @Assisted ShoppingCartItem item); @Override void delete(); @Override void onQuantityChangedInView(int quantity); @Override void onShoppingCartQuantityChanged(ShoppingCartQuantityChangeEvent event);  }
@Test public void onQuantityChangedInView_deletesItem_whenQuantityIs0() { presenter.onQuantityChangedInView(0); verify(currentOrder).removeItem(currentShoppingCartItem); }
@Test public void onQuantityChangedInView_updatesQuantityInItem_whenQuantityIsOver0() { currentShoppingCartItem.setQuantity(4); presenter.onQuantityChangedInView(2); assertThat(currentShoppingCartItem.getQuantity()).isEqualTo(2); }