2 * XdccDownloader - ReplyTest.java - Copyright © 2013 David Roden
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.
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.
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/>.
18 package net.pterodactylus.irc;
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;
25 import com.google.common.base.Optional;
26 import org.testng.annotations.Test;
29 * Tests for {@link Reply}.
31 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
33 public class ReplyTest {
36 public void testParser() {
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"));
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"));