WoodcuttingPlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() == ChatMessageType.SPAM || event.getType() == ChatMessageType.GAMEMESSAGE) { if (WOOD_CUT_PATTERN.matcher(event.getMessage()).matches()) { if (session == null) { session = new WoodcuttingSession(); } session.setLastChopping(); } if (event.getMessage().contains("A bird's nest falls out of the tree") && config.showNestNotification()) { notifier.notify("A bird nest has spawned!"); } } }  @Subscribe void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked); @Subscribe void onGameTick(GameTick gameTick); @Subscribe void onChatMessage(ChatMessage event); @Subscribe void onGameObjectSpawned(final GameObjectSpawned event); @Subscribe void onGameObjectDespawned(final GameObjectDespawned event); @Subscribe void onGameObjectChanged(final GameObjectChanged event); @Subscribe void onGameStateChanged(final GameStateChanged event); @Subscribe void onAnimationChanged(final AnimationChanged event);  }
@Test public void testLogs() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You get some logs.", "", 0); woodcuttingPlugin.onChatMessage(chatMessage); assertNotNull(woodcuttingPlugin.getSession()); }
@Test public void testOakLogs() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You get some oak logs.", "", 0); woodcuttingPlugin.onChatMessage(chatMessage); assertNotNull(woodcuttingPlugin.getSession()); }
@Test public void testArcticLogs() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You get an arctic log.", "", 0); woodcuttingPlugin.onChatMessage(chatMessage); assertNotNull(woodcuttingPlugin.getSession()); }
@Test public void testMushrooms() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You get some mushrooms.", "", 0); woodcuttingPlugin.onChatMessage(chatMessage); assertNotNull(woodcuttingPlugin.getSession()); }
@Test public void testBirdsNest() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BIRDS_NEST_MESSAGE, "", 0); when(woodcuttingConfig.showNestNotification()).thenReturn(true); woodcuttingPlugin.onChatMessage(chatMessage); verify(notifier).notify("A bird nest has spawned!"); when(woodcuttingConfig.showNestNotification()).thenReturn(false); woodcuttingPlugin.onChatMessage(chatMessage); verifyNoMoreInteractions(notifier); }