🚧 Parse token from DCC SEND
[xudocci.git] / src / test / java / net / pterodactylus / irc / connection / CtcpHandlerTest.java
index e1463c9..c8d6306 100644 (file)
@@ -3,6 +3,8 @@ package net.pterodactylus.irc.connection;
 import static net.pterodactylus.irc.Source.parseSource;
 import static net.pterodactylus.irc.connection.Replies.createReply;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.is;
 import static org.mockito.ArgumentCaptor.forClass;
 import static org.mockito.Matchers.anyObject;
@@ -131,6 +133,16 @@ public class CtcpHandlerTest {
        }
 
        @Test
+       public void dccCommandWithTokenIsRecognizedCorrectly() {
+               handler.handleReply(createReply(parseSource("User!user@host"), "PRIVMSG", "\u0001DCC SEND filename 1234 0 12345 T123\u0001"));
+               ArgumentCaptor<DccSendReceived> dccSendReceivedCaptor = forClass(DccSendReceived.class);
+               verify(eventBus).post(dccSendReceivedCaptor.capture());
+               assertThat(dccSendReceivedCaptor.getAllValues(), hasSize(1));
+               DccSendReceived dccSendReceived = dccSendReceivedCaptor.getValue();
+               assertThat(dccSendReceived.token(), equalTo("T123"));
+       }
+
+       @Test
        public void dccAcceptCommandIsRecognized() {
                handler.handleReply(createReply(parseSource("User!user@host"),
                                "NOTICE",