4ea7157b841e9dfabec590fdcffd9d17fbda60d8
[xudocci.git] / src / test / java / net / pterodactylus / irc / ReplyTest.java
1 /*
2  * XdccDownloader - ReplyTest.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.irc;
19
20 import static org.hamcrest.MatcherAssert.assertThat;
21 import static org.hamcrest.Matchers.hasSize;
22 import static org.hamcrest.Matchers.is;
23 import static org.hamcrest.Matchers.notNullValue;
24
25 import com.google.common.base.Optional;
26 import org.testng.annotations.Test;
27
28 /**
29  * Tests for {@link Reply}.
30  *
31  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
32  */
33 public class ReplyTest {
34
35         @Test
36         public void testParser() {
37                 Reply reply;
38
39                 reply = Reply.parseLine("NOTICE AUTH :*** Processing your connection");
40                 assertThat(reply, notNullValue());
41                 assertThat(reply.source(), is(Optional.<Source>absent()));
42                 assertThat(reply.command(), is("NOTICE"));
43                 assertThat(reply.parameters(), hasSize(2));
44                 assertThat(reply.parameters().get(0), is("AUTH"));
45                 assertThat(reply.parameters().get(1), is("*** Processing your connection"));
46
47                 reply = Reply.parseLine(":ParaDMON!services@paraphysics.services PRIVMSG QshelTier :\u0001VERSION\u0001");
48                 assertThat(reply, notNullValue());
49                 assertThat(reply.source(), is(Optional.of(Source.parseSource("ParaDMON!services@paraphysics.services"))));
50                 assertThat(reply.command(), is("PRIVMSG"));
51                 assertThat(reply.parameters(), hasSize(2));
52                 assertThat(reply.parameters().get(0), is("QshelTier"));
53                 assertThat(reply.parameters().get(1), is("\u0001VERSION\u0001"));
54         }
55
56 }