package net.pterodactylus.irc.connection;
import static java.util.Arrays.asList;
+import static net.pterodactylus.irc.connection.Replies.createReply;
import static net.pterodactylus.irc.event.ChannelNotJoined.Reason.badChannelKey;
import static net.pterodactylus.irc.event.ChannelNotJoined.Reason.banned;
import static net.pterodactylus.irc.event.ChannelNotJoined.Reason.inviteOnly;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import net.pterodactylus.irc.Connection;
-import net.pterodactylus.irc.Reply;
import net.pterodactylus.irc.event.ChannelNotJoined;
import net.pterodactylus.irc.event.ChannelNotJoined.Reason;
}
}
- private Reply createReply(String command) {
- Reply reply = mock(Reply.class);
- return when(reply.command()).thenReturn(command).getMock();
- }
-
@Test
public void bannedChannelNotJoinedIsRecognizedCorrectly() {
handler.handleReply(createReply("474", "#test"));
verifyReasonIs(registeredNicknamesOnly);
}
- private Reply createReply(String command, String channel) {
- final Reply reply = mock(Reply.class);
- when(reply.command()).thenReturn(command);
- when(reply.parameters()).thenReturn(asList(":some.server", channel));
- return reply;
- }
-
}
--- /dev/null
+package net.pterodactylus.irc.connection;
+
+import static java.util.Arrays.asList;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import net.pterodactylus.irc.Reply;
+
+/**
+ * Helper class to mock {@link Reply}s for testing {@link Handler}s.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class Replies {
+
+ public static Reply createReply(String command, String channel) {
+ final Reply reply = mock(Reply.class);
+ when(reply.command()).thenReturn(command);
+ when(reply.parameters()).thenReturn(asList(":some.server", channel));
+ return reply;
+ }
+
+ public static Reply createReply(String command) {
+ Reply reply = mock(Reply.class);
+ return when(reply.command()).thenReturn(command).getMock();
+ }
+
+}