@Test public void createMenuItem() throws Exception { final Collection<MenuItem> menuItems = menuService.getMenuItems(); final int initialSize = menuItems.size(); MenuItem newItem = new MenuItem(); newItem.setId(-1); newItem.setName("Hawt New Stuff"); newItem.setDescription("So new and yet so cool"); newItem.setCost(3); assertFalse(menuItems.contains(newItem)); int newItemId = menuService.createMenuItem(newItem); assertNotEquals(newItem.getId(), newItemId); final MenuItem menuItem = menuService.getMenuItem(newItemId); assertNotEquals(newItem, menuItem); assertEquals(newItemId, menuItem.getId()); assertEquals(newItem.getName(), menuItem.getName()); assertEquals(newItem.getCost(), menuItem.getCost()); assertEquals(newItem.getDescription(), menuItem.getDescription()); Collection<MenuItem> newMenuItems = menuService.getMenuItems(); assertTrue(newMenuItems.size() > initialSize); assertTrue(newMenuItems.contains(menuItem)); }
public int createMenuItem(MenuItem item) throws MenuItemInvalidException { return createMenuItem(ids.incrementAndGet(), item); }
MenuService { public int createMenuItem(MenuItem item) throws MenuItemInvalidException { return createMenuItem(ids.incrementAndGet(), item); } }
MenuService { public int createMenuItem(MenuItem item) throws MenuItemInvalidException { return createMenuItem(ids.incrementAndGet(), item); } MenuService(); }
MenuService { public int createMenuItem(MenuItem item) throws MenuItemInvalidException { return createMenuItem(ids.incrementAndGet(), item); } MenuService(); int createMenuItem(MenuItem item); int createMenuItem(int itemId, MenuItem item); Collection<MenuItem> getMenuItems(); MenuItem getMenuItem(int itemId); void updateMenuItem(int itemId, MenuItem item); void removeMenuItem(int itemId); }
MenuService { public int createMenuItem(MenuItem item) throws MenuItemInvalidException { return createMenuItem(ids.incrementAndGet(), item); } MenuService(); int createMenuItem(MenuItem item); int createMenuItem(int itemId, MenuItem item); Collection<MenuItem> getMenuItems(); MenuItem getMenuItem(int itemId); void updateMenuItem(int itemId, MenuItem item); void removeMenuItem(int itemId);  }