Exemplo n.º 1
0
  @Test
  public void testMsgFromAdmin() {

    String channelMsg =
        ":[email protected] PRIVMSG #channelname :!b flirt nick";
    String adminMsg =
        ":[email protected] PRIVMSG #channelname :!botnick flirt nick";

    //  Set up bot and command
    IRCBot mockBot = new IRCBot(false);
    FlirtCommand flirtCommand = new FlirtCommand(mockBot);

    IRCMsg badFlirtMsg = mockBot.getIRCMsgHandler().createAndDecorateMsg(channelMsg);
    Assert.assertFalse(flirtCommand.listen(badFlirtMsg));
    String pollResult = mockBot.getOutboundMsgQ().poll();
    Assert.assertNull(pollResult);

    IRCMsg goodFlirt = mockBot.getIRCMsgHandler().createAndDecorateMsg(adminMsg);
    Assert.assertTrue(goodFlirt.isFromAdmin());

    mockBot.getIRCMsgHandler().handleMsg(adminMsg);
    pollResult = mockBot.getOutboundMsgQ().poll();
    Assert.assertNotNull(pollResult);
  }