Add class for reply source information.
[xudocci.git] / src / test / java / net / pterodactylus / irc / SourceTest.java
diff --git a/src/test/java/net/pterodactylus/irc/SourceTest.java b/src/test/java/net/pterodactylus/irc/SourceTest.java
new file mode 100644 (file)
index 0000000..84f4a85
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * XdccDownloader - SourceTest.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.irc;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import com.google.common.base.Optional;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for {@link Source}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class SourceTest {
+
+       @Test
+       public void testParser() {
+               Source source;
+
+               source = Source.parseSource("server.irc.net");
+               assertThat(source, notNullValue());
+               assertThat(source.nick(), is(Optional.<String>absent()));
+               assertThat(source.username(), is(Optional.<String>absent()));
+               assertThat(source.server(), is("server.irc.net"));
+
+               source = Source.parseSource("foo!bar@server.irc.net");
+               assertThat(source, notNullValue());
+               assertThat(source.nick(), is(Optional.of("foo")));
+               assertThat(source.username(), is(Optional.of("bar")));
+               assertThat(source.server(), is("server.irc.net"));
+       }
+
+}