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.
*/
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;
}