@Test public void addItem() { when(inventoryPages.getPage(anyInt())).thenReturn(mock(Inventory.class)); MultiPageGui multiPageGui = new MultiPageGui(mock(PlayerPages.class), inventoryPages, mock(SlotActions.class), mock(Server.class), playerPageRearranger); Inventory inventory = mock(Inventory.class); when(inventoryPages.getPage(eq(1))).thenReturn(inventory); InventoryItem item = mock(InventoryItem.class); ItemStack itemStack = mock(ItemStack.class); when(item.getItemStack()).thenReturn(itemStack); when(item.getSlot()).thenReturn(5); when(item.getPage()).thenReturn(1); when(inventoryPages.getTotalPages()).thenReturn(0); multiPageGui.addItem(item); verify(inventoryPages).addNewPage(); verify(inventory).setItem(eq(5), eq(itemStack)); }
@Override public void addItem(InventoryItem item) { int page = item.getPage(); if (page > inventoryPages.getTotalPages()) { inventoryPages.addNewPage(); } this.addItem(inventoryPages.getPage(page), item); }
MultiPageGui implements GUI { @Override public void addItem(InventoryItem item) { int page = item.getPage(); if (page > inventoryPages.getTotalPages()) { inventoryPages.addNewPage(); } this.addItem(inventoryPages.getPage(page), item); } }
MultiPageGui implements GUI { @Override public void addItem(InventoryItem item) { int page = item.getPage(); if (page > inventoryPages.getTotalPages()) { inventoryPages.addNewPage(); } this.addItem(inventoryPages.getPage(page), item); }  }
MultiPageGui implements GUI { @Override public void addItem(InventoryItem item) { int page = item.getPage(); if (page > inventoryPages.getTotalPages()) { inventoryPages.addNewPage(); } this.addItem(inventoryPages.getPage(page), item); }  @Override void displayTo(Player player); @Override void clear(); @Override void addButton(InventoryItem inventoryItem, Executable executable); @Override void addItem(InventoryItem item); @Override void removeItem(int slot, int page); }
MultiPageGui implements GUI { @Override public void addItem(InventoryItem item) { int page = item.getPage(); if (page > inventoryPages.getTotalPages()) { inventoryPages.addNewPage(); } this.addItem(inventoryPages.getPage(page), item); }  @Override void displayTo(Player player); @Override void clear(); @Override void addButton(InventoryItem inventoryItem, Executable executable); @Override void addItem(InventoryItem item); @Override void removeItem(int slot, int page);  }