HttpCall { public HttpCall setParams(String key1, @Nullable String value1, String... otherKeysAndNames) { checkArgument(otherKeysAndNames.length % 2 == 0, "Expecting even number of arguments: %s", Arrays.toString(otherKeysAndNames)); parameters.put(key1, value1); for (int i = 0; i < otherKeysAndNames.length; i++) { parameters.put(otherKeysAndNames[i], otherKeysAndNames[i + 1]); i++; } return this; } HttpCall(OkHttpClient okClient, HttpUrl baseUrl); HttpUrl getBaseUrl(); HttpCall setMethod(HttpMethod m); HttpCall setCredentials(String login, @Nullable String password); HttpCall setAdminCredentials(); HttpCall setAuthenticationToken(String token); HttpCall setParam(String key, @Nullable String value); HttpCall setParams(String key1, @Nullable String value1, String... otherKeysAndNames); HttpCall setHeader(String key, String value); HttpCall setTimeoutMs(long timeoutMs); HttpResponse execute(); HttpResponse executeUnsafely(); void downloadToFile(File file); File downloadToDirectory(File dir);  }
@Test public void setParams_throws_IAE_if_odd_number_of_varargs() throws Exception { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Expecting even number of arguments: [one, two, three]"); newCall("api/system/ping") .setParams("foo", "foz", "one", "two", "three"); }