### Question:
ItemChargePlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage event) { String message = event.getMessage(); Matcher dodgyCheckMatcher = DODGY_CHECK_PATTERN.matcher(message); Matcher dodgyProtectMatcher = DODGY_PROTECT_PATTERN.matcher(message); Matcher dodgyBreakMatcher = DODGY_BREAK_PATTERN.matcher(message); if (event.getType() == ChatMessageType.SERVER || event.getType() == ChatMessageType.FILTERED) { if (config.recoilNotification() && message.contains(RING_OF_RECOIL_BREAK_MESSAGE)) { notifier.notify("Your Ring of Recoil has shattered"); } else if (dodgyBreakMatcher.find()) { if (config.dodgyNotification()) { notifier.notify("Your dodgy necklace has crumbled to dust."); } setDodgyCharges(MAX_DODGY_CHARGES); } else if (dodgyCheckMatcher.find()) { setDodgyCharges(Integer.parseInt(dodgyCheckMatcher.group(1))); } else if (dodgyProtectMatcher.find()) { setDodgyCharges(Integer.parseInt(dodgyProtectMatcher.group(1))); } } }  @Subscribe void onChatMessage(ChatMessage event);  }### Answer:
@Test public void testOnChatMessage() { ChatMessage chatMessage = new ChatMessage(ChatMessageType.SERVER, "", CHECK, ""); itemChargePlugin.onChatMessage(chatMessage); assertEquals(10, itemChargePlugin.getDodgyCharges()); chatMessage = new ChatMessage(ChatMessageType.SERVER, "", PROTECT, ""); itemChargePlugin.onChatMessage(chatMessage); assertEquals(9, itemChargePlugin.getDodgyCharges()); chatMessage = new ChatMessage(ChatMessageType.SERVER, "", PROTECT_1, ""); itemChargePlugin.onChatMessage(chatMessage); assertEquals(1, itemChargePlugin.getDodgyCharges()); chatMessage = new ChatMessage(ChatMessageType.SERVER, "", BREAK, ""); itemChargePlugin.onChatMessage(chatMessage); assertEquals(10, itemChargePlugin.getDodgyCharges()); }