SmeltingPlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SPAM) { return; } if (event.getMessage().startsWith("You retrieve a bar of")) { if (session == null) { session = new SmeltingSession(); } session.increaseBarsSmelted(); } else if (event.getMessage().startsWith("You remove the cannonballs from the mould")) { if (session == null) { session = new SmeltingSession(); } session.increaseCannonBallsSmelted(); } }  @Subscribe void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked); @Subscribe void onChatMessage(ChatMessage event); @Subscribe void onGameTick(GameTick event);  }
@Test public void testCannonballs() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", SMELT_CANNONBALL, "", 0); smeltingPlugin.onChatMessage(chatMessage); SmeltingSession smeltingSession = smeltingPlugin.getSession(); assertNotNull(smeltingSession); assertEquals(4, smeltingSession.getCannonBallsSmelted()); }
@Test public void testBars() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", SMELT_BAR, "", 0); smeltingPlugin.onChatMessage(chatMessage); SmeltingSession smeltingSession = smeltingPlugin.getSession(); assertNotNull(smeltingSession); assertEquals(1, smeltingSession.getBarsSmelted()); }