@Test public void testIfHistoryChannelMaxLimit() { assertEquals(7, history.getLastChannelEvents(channel).size()); assertEquals( "Message 1", history .getLastChannelEvents(channel) .get(history.getLastChannelEvents(channel).size() - 1) .getMessage()); for (int i = history.getLastChannelEvents(channel).size(); i < History.MAX_EVENTS_IN_CHANNEL_HISOTRY; i++) { history.appendChannelHistory( channel, createPrivMsgEvent( "freenode", melwil.getNickname(), channel.getChannelname(), "Flood " + i)); } assertEquals( History.MAX_EVENTS_IN_CHANNEL_HISOTRY, history.getLastChannelEvents(channel).size()); assertEquals( "Message 1", history .getLastChannelEvents(channel) .get(history.getLastChannelEvents(channel).size() - 1) .getMessage()); history.appendChannelHistory( channel, createPrivMsgEvent( "freenode", melwil.getNickname(), channel.getChannelname(), "newLineAtTop")); assertEquals( History.MAX_EVENTS_IN_CHANNEL_HISOTRY, history.getLastChannelEvents(channel).size()); assertEquals( "Message 2", history .getLastChannelEvents(channel) .get(history.getLastChannelEvents(channel).size() - 1) .getMessage()); assertEquals("newLineAtTop", history.getLastChannelEvents(channel).get(0).getMessage()); }
@Before public void setUp() { history = new History(); rockj = new Nick("Rockj"); fictive = new Nick("Fictive"); melwil = new Nick("melwil"); history.appendHistory(rockj, createJoinEvent("freenode", "#test", rockj.getNickname())); history.appendHistory(fictive, createJoinEvent("freenode", "#test", fictive.getNickname())); history.appendHistory(melwil, createJoinEvent("freenode", "#test", melwil.getNickname())); history.appendHistory( rockj, createPrivMsgEvent( "freenode", rockj.getNickname(), "#test", "This is a trolling message, what's up?!")); history.nickChangeHistory(createNickEvent("freenode", fictive.getNickname(), "fictiveLulz")); fictive.setNickname("fictiveLulz"); for (int i = 0; i < 3; i++) { history.appendHistory( melwil, createPrivMsgEvent("freenode", melwil.getNickname(), "#test", "Flood " + i + "!")); } // Channel history here channel = new Channel("#test"); history.appendChannelHistory( channel, createPrivMsgEvent("freenode", rockj.getNickname(), channel.getChannelname(), "Message 1")); history.appendChannelHistory( channel, createPrivMsgEvent("freenode", rockj.getNickname(), channel.getChannelname(), "Message 2")); history.appendChannelHistory( channel, createPrivMsgEvent("freenode", rockj.getNickname(), channel.getChannelname(), "Message 3")); history.appendChannelHistory( channel, createPrivMsgEvent("freenode", rockj.getNickname(), channel.getChannelname(), "Message 4")); history.appendChannelHistory( channel, createPrivMsgEvent( "freenode", fictive.getNickname(), channel.getChannelname(), "Message 5")); history.appendChannelHistory( channel, createPrivMsgEvent("freenode", rockj.getNickname(), channel.getChannelname(), "Message 6")); history.appendChannelHistory( channel, createPrivMsgEvent("freenode", rockj.getNickname(), channel.getChannelname(), "Message 7")); }