public void testShouldSwitchPagesBackAndForth() {
Mock catalogServiceMock = mock(CatalogService.class);
CartBean bean = new CartBean((CatalogService) catalogServiceMock.proxy());
assertEquals(AbstractBean.SUCCESS, bean.viewCart());
Cart cart = new Cart();
for (int i = 0; i < cart.getCartItemList().getPageSize() * 2; i++) {
cart.getCartItemList().add(new Item());
}
bean.setCart(cart);
bean.setPageDirection("next");
assertEquals(AbstractBean.SUCCESS, bean.switchCartPage());
assertEquals(1, cart.getCartItemList().getPageIndex());
bean.setPageDirection("previous");
assertEquals(AbstractBean.SUCCESS, bean.switchCartPage());
assertEquals(0, cart.getCartItemList().getPageIndex());
}