@Test public void rebuildPageByIndex() { PagesList pagesList = mock(PagesList.class); Server server = mock(Server.class); PageBuilder pageBuilder = new PageBuilder( "Title", server, pagesList ); Inventory src = mock(Inventory.class); when(src.getSize()).thenReturn(10); ItemStack content = new ItemStack(Material.AIR); when(src.getItem(eq(5))).thenReturn(content); Inventory newInv = mock(Inventory.class); when(server.createInventory(any(), anyInt(), any())).thenReturn(newInv); when(pagesList.get(0)).thenReturn(src); pageBuilder.rebuildPageByIndex(0); verify(pagesList).set(eq(0), eq(newInv)); verify(newInv).setItem(eq(5), eq(content)); }
public void rebuildPageByIndex(int index) { Inventory current = pages.get(index); String newTitle = pageTitle(index, pages.size()); Inventory newInventory = server.createInventory(null, INVENTORY_SIZE, newTitle); for (int i = 0; i < current.getSize(); i++) { newInventory.setItem(i, current.getItem(i)); } this.pages.set(index, newInventory); }
PageBuilder { public void rebuildPageByIndex(int index) { Inventory current = pages.get(index); String newTitle = pageTitle(index, pages.size()); Inventory newInventory = server.createInventory(null, INVENTORY_SIZE, newTitle); for (int i = 0; i < current.getSize(); i++) { newInventory.setItem(i, current.getItem(i)); } this.pages.set(index, newInventory); } }
PageBuilder { public void rebuildPageByIndex(int index) { Inventory current = pages.get(index); String newTitle = pageTitle(index, pages.size()); Inventory newInventory = server.createInventory(null, INVENTORY_SIZE, newTitle); for (int i = 0; i < current.getSize(); i++) { newInventory.setItem(i, current.getItem(i)); } this.pages.set(index, newInventory); }  }
PageBuilder { public void rebuildPageByIndex(int index) { Inventory current = pages.get(index); String newTitle = pageTitle(index, pages.size()); Inventory newInventory = server.createInventory(null, INVENTORY_SIZE, newTitle); for (int i = 0; i < current.getSize(); i++) { newInventory.setItem(i, current.getItem(i)); } this.pages.set(index, newInventory); }  void rebuildSwitchersAfterRemoval(int removedPageIndex); void rebuildPageSwitchers(int pageIndex); void addSwitchItems(int i, Inventory page); void rebuildPageByIndex(int index); String pageTitle(int index, int total); }
PageBuilder { public void rebuildPageByIndex(int index) { Inventory current = pages.get(index); String newTitle = pageTitle(index, pages.size()); Inventory newInventory = server.createInventory(null, INVENTORY_SIZE, newTitle); for (int i = 0; i < current.getSize(); i++) { newInventory.setItem(i, current.getItem(i)); } this.pages.set(index, newInventory); }  void rebuildSwitchersAfterRemoval(int removedPageIndex); void rebuildPageSwitchers(int pageIndex); void addSwitchItems(int i, Inventory page); void rebuildPageByIndex(int index); String pageTitle(int index, int total);  }