@Test
  public void messageArrivedShouldLogIfUnableToParseUserCodeInMessage() {
    messageParser.messageArrived("a16320462!LOGON#Christian:", "192.168.1.1");

    final ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class);

    verify(log)
        .log(
            eq(Level.SEVERE),
            eq(
                "Failed to parse message. message=a16320462!LOGON#Christian:, ipAddress=192.168.1.1"),
            exceptionCaptor.capture());

    checkException(exceptionCaptor, NumberFormatException.class, "For input string: \"a16320462\"");
  }
  @Test
  public void messageArrivedShouldLogIfUnableToFindNecessaryDetailsInMessage() {
    messageParser.messageArrived("Error", "192.168.1.1");

    final ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class);

    verify(log)
        .log(
            eq(Level.SEVERE),
            eq("Failed to parse message. message=Error, ipAddress=192.168.1.1"),
            exceptionCaptor.capture());

    checkException(
        exceptionCaptor, StringIndexOutOfBoundsException.class, "String index out of range: -1");
  }
  @Test
  public void messageArrivedShouldLogIfPrivateChatPortCouldNotBeParsed() {
    messageParser.messageArrived(
        "16320462!CLIENT#Christian:(KouChat v1.3.0 Swing)[2688]{Linux}<a40657>", "192.168.1.1");

    final ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class);

    verify(log)
        .log(
            eq(Level.WARNING),
            eq(
                "Failed to parse private chat port. "
                    + "message=16320462!CLIENT#Christian:(KouChat v1.3.0 Swing)[2688]{Linux}<a40657>, "
                    + "ipAddress=192.168.1.1"),
            exceptionCaptor.capture());

    checkException(exceptionCaptor, NumberFormatException.class, "For input string: \"a40657\"");
  }