@Test public void switchPage() { InventoryPages inventoryPages = mock(InventoryPages.class); PlayerPages playerPages= mock(PlayerPages.class); Server server = mock(Server.class); PageSwitcher pageSwitcher = new PageSwitcher( inventoryPages,playerPages,server ); UUID uuid = UUID.randomUUID(); Player player = mock(Player.class); when(server.getPlayer(eq(uuid))).thenReturn(player); when(playerPages.switchPage(eq(uuid), any())).thenReturn(5); Inventory inventory = mock(Inventory.class); when(inventoryPages.getPage(eq(5))).thenReturn(inventory); pageSwitcher.switchPage(uuid, operand -> operand + 1); verify(player).openInventory(eq(inventory)); }
public void switchPage(UUID uuid, IntUnaryOperator function) { Player player = server.getPlayer(uuid); player.closeInventory(); int switchedTo = playerPages.switchPage(uuid, function); player.openInventory(inventoryPages.getPage(switchedTo)); }
PageSwitcher { public void switchPage(UUID uuid, IntUnaryOperator function) { Player player = server.getPlayer(uuid); player.closeInventory(); int switchedTo = playerPages.switchPage(uuid, function); player.openInventory(inventoryPages.getPage(switchedTo)); } }
PageSwitcher { public void switchPage(UUID uuid, IntUnaryOperator function) { Player player = server.getPlayer(uuid); player.closeInventory(); int switchedTo = playerPages.switchPage(uuid, function); player.openInventory(inventoryPages.getPage(switchedTo)); }  }
PageSwitcher { public void switchPage(UUID uuid, IntUnaryOperator function) { Player player = server.getPlayer(uuid); player.closeInventory(); int switchedTo = playerPages.switchPage(uuid, function); player.openInventory(inventoryPages.getPage(switchedTo)); }  void switchPage(UUID uuid, IntUnaryOperator function); }
PageSwitcher { public void switchPage(UUID uuid, IntUnaryOperator function) { Player player = server.getPlayer(uuid); player.closeInventory(); int switchedTo = playerPages.switchPage(uuid, function); player.openInventory(inventoryPages.getPage(switchedTo)); }  void switchPage(UUID uuid, IntUnaryOperator function);  }