@Test public void testIfHistoryStaysWithUsAfterNickChange() { Nick copyOfFictive = new Nick(fictive.getNickname()); copyOfFictive.setNickname("fictive"); assertEquals(0, history.getLastEvents(copyOfFictive).size()); assertEquals(2, history.getLastEvents(fictive).size()); }
@Test public void testLastActionByRockj() { Event event = history.getLastEvents(rockj).get(0); assertEquals((PrivMsgEvent) event, event); PrivMsgEvent privMsgEvent = (PrivMsgEvent) event; assertEquals("This is a trolling message, what's up?!", privMsgEvent.getMessage()); assertEquals(2, history.getLastEvents(rockj).size()); }
@Test public void testIfHistoryDoesntHoldMoreEventsThenMaxConstant() { assertEquals(4, history.getLastEvents(melwil).size()); history.appendHistory( melwil, createPrivMsgEvent("freenode", melwil.getNickname(), "#test", "hoho now at max")); List<Event> melwilsHistoryAfter5Changes = history.getLastEvents(melwil); System.out.println(Arrays.toString(melwilsHistoryAfter5Changes.toArray())); assertEquals(History.MAX_EVENTS_IN_HISTORY_PER_NICK, melwilsHistoryAfter5Changes.size()); assertEquals( "hoho now at max", ((PrivMsgEvent) melwilsHistoryAfter5Changes.get(0)).getMessage()); assertTrue( melwilsHistoryAfter5Changes.get(History.MAX_EVENTS_IN_HISTORY_PER_NICK - 1) instanceof JoinEvent); assertEquals( "#test", ((JoinEvent) melwilsHistoryAfter5Changes.get(History.MAX_EVENTS_IN_HISTORY_PER_NICK - 1)) .getChannel()); history.appendHistory( melwil, createPartEvent("freenode", "#test", melwil.getNickname(), "troll")); assertEquals(History.MAX_EVENTS_IN_HISTORY_PER_NICK, history.getLastEvents(melwil).size()); assertEquals( "hoho now at max", ((PrivMsgEvent) history.getLastEvents(melwil).get(1)).getMessage()); assertTrue(history.getLastEvents(melwil).get(0) instanceof PartEvent); assertEquals("#test", ((PartEvent) history.getLastEvents(melwil).get(0)).getChannel()); }