CookingPlugin extends Plugin { @Subscribe public void onGraphicChanged(GraphicChanged graphicChanged) { Player player = client.getLocalPlayer(); if (graphicChanged.getActor() != player) { return; } if (player.getGraphic() == GraphicID.WINE_MAKE && config.fermentTimer()) { Optional<FermentTimer> fermentTimerOpt = infoBoxManager.getInfoBoxes().stream() .filter(FermentTimer.class::isInstance) .map(FermentTimer.class::cast) .findAny(); if (fermentTimerOpt.isPresent()) { FermentTimer fermentTimer = fermentTimerOpt.get(); fermentTimer.reset(); } else { FermentTimer fermentTimer = new FermentTimer(itemManager.getImage(ItemID.JUG_OF_WINE), this); infoBoxManager.addInfoBox(fermentTimer); } } }  @Subscribe void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked); @Subscribe void onGameTick(GameTick gameTick); @Subscribe void onGraphicChanged(GraphicChanged graphicChanged); @Subscribe void onChatMessage(ChatMessage event);  }
@Test public void testOnGraphicChanged() { Player player = mock(Player.class); when(player.getGraphic()).thenReturn(GraphicID.WINE_MAKE); when(config.fermentTimer()).thenReturn(true); when(client.getLocalPlayer()).thenReturn(player); GraphicChanged graphicChanged = new GraphicChanged(); graphicChanged.setActor(player); cookingPlugin.onGraphicChanged(graphicChanged); verify(infoBoxManager).addInfoBox(any(FermentTimer.class)); }