Add unit test for CTCP handler; refactor CTCP handler.
[xudocci.git] / src / test / java / net / pterodactylus / irc / connection / Replies.java
index 214c3d4..841d3af 100644 (file)
@@ -1,10 +1,15 @@
 package net.pterodactylus.irc.connection;
 
+import static com.google.common.base.Optional.fromNullable;
 import static java.util.Arrays.asList;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import net.pterodactylus.irc.Reply;
+import net.pterodactylus.irc.Source;
 
 /**
  * Helper class to mock {@link Reply}s for testing {@link Handler}s.
@@ -13,10 +18,20 @@ import net.pterodactylus.irc.Reply;
  */
 public class Replies {
 
-       public static Reply createReply(String command, String channel) {
+       public static Reply createReply(Source source, String command,
+                       String... parameters) {
+               Reply reply = createReply(command, parameters);
+               when(reply.source()).thenReturn(fromNullable(source));
+               return reply;
+       }
+
+       public static Reply createReply(String command, String... parameters) {
                final Reply reply = mock(Reply.class);
                when(reply.command()).thenReturn(command);
-               when(reply.parameters()).thenReturn(asList(":some.server", channel));
+               List<String> allParameters = new ArrayList<>();
+               allParameters.add(":some.server");
+               allParameters.addAll(asList(parameters));
+               when(reply.parameters()).thenReturn(allParameters);
                return reply;
        }