CartItemPresenter extends PresenterWidget<CartItemPresenter.MyView> implements CartItemUiHandlers, ShoppingCartQuantityUpdatedEventHandler { @Override public void onShoppingCartQuantityChanged(ShoppingCartQuantityChangeEvent event) { if (item == event.getExistingItem()) { getView().updateQuantity(event.getNewQuantity()); } } @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 onShoppingCartQuantityUpdated_updatesViewWithNewQuantity_whenCartItemIsSameAsCurrentOne() { ShoppingCartQuantityChangeEvent updateEvent = new ShoppingCartQuantityChangeEvent(currentShoppingCartItem, NEW_QUANTITY); presenter.onShoppingCartQuantityChanged(updateEvent); verify(view).updateQuantity(NEW_QUANTITY); }
@Test public void onShoppingCartQuantityUpdated_doesNothing_whenItemIsNotTheSameAsCurrentOne() { ShoppingCartItem otherItem = mock(ShoppingCartItem.class); ShoppingCartQuantityChangeEvent updateEvent = new ShoppingCartQuantityChangeEvent(otherItem, SOME_QUANTITY); presenter.onShoppingCartQuantityChanged(updateEvent); verify(view, never()).updateQuantity(anyInt()); }