### Question:
WintertodtPlugin extends Plugin { @Subscribe void onVarbitChanged(VarbitChanged varbitChanged) { int timerValue = client.getVar(Varbits.WINTERTODT_TIMER); if (timerValue != previousTimerValue) { int timeToNotify = config.roundNotification(); if (timeToNotify > 0) { int timeInSeconds = timerValue * 30 / 50; int prevTimeInSeconds = previousTimerValue * 30 / 50; log.debug("Seconds left until round start: {}", timeInSeconds); if (prevTimeInSeconds > timeToNotify && timeInSeconds <= timeToNotify) { notifier.notify("Wintertodt round is about to start"); } } previousTimerValue = timerValue; } }    }### Answer:
@Test public void matchStartingNotification_shouldNotify_when15SecondsOptionSelected() { when(config.roundNotification()).thenReturn(15); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(35); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(25); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); verify(notifier, times(1)).notify("Wintertodt round is about to start"); }
@Test public void matchStartingNotification_shouldNotify_when10SecondsOptionSelected() { when(config.roundNotification()).thenReturn(10); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(20); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(16); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); verify(notifier, times(1)).notify("Wintertodt round is about to start"); }
@Test public void matchStartingNotification_shouldNotify_when5SecondsOptionSelected() { when(config.roundNotification()).thenReturn(5); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(10); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(8); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); verify(notifier, times(1)).notify("Wintertodt round is about to start"); }
@Test public void matchStartingNotification_shouldNotifyOnce() { when(config.roundNotification()).thenReturn(5); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(0); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(10); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(8); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(6); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(5); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(4); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); verify(notifier, times(1)).notify("Wintertodt round is about to start"); }
@Test public void matchStartingNotification_shouldNotNotify_whenNoneOptionSelected() { when(config.roundNotification()).thenReturn(5); when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(25); wintertodtPlugin.onVarbitChanged(new VarbitChanged()); verify(notifier, times(0)).notify("Wintertodt round is about to start"); }