/**
 * The MIT License
 *
 * Copyright for portions of OpenUnirest/uniresr-java are held by Mashape (c) 2013 as part of Kong/unirest-java.
 * All other copyright for OpenUnirest/unirest-java are held by OpenUnirest (c) 2018.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package BehaviorTests;

import unirest.HttpResponse;
import unirest.JsonNode;
import unirest.Unirest;
import org.junit.Test;

import java.util.Arrays;

public class QueryStringTest extends BddTest {
    @Test
    public void testGetQueryStrings() {
       Unirest.get(MockServer.GET)
                .queryString("name", "mark")
                .queryString("nick", "thefosk")
                .asObject(RequestCapture.class)
                .getBody()
                .assertParam("name", "mark")
                .assertParam("nick", "thefosk");
    }

    @Test
    public void canPassQueryParamsDirectlyOnUriOrWithMethod() {
        Unirest.get(MockServer.GET + "?name=mark")
                .asObject(RequestCapture.class)
                .getBody()
                .assertParam("name", "mark");

        Unirest.get(MockServer.GET)
                .queryString("name", "mark2")
                .asObject(RequestCapture.class)
                .getBody()
                .assertParam("name", "mark2");
    }

    @Test
    public void multipleParams() {
        Unirest.get(MockServer.GET + "?name=ringo")
                .queryString("name", "paul")
                .queryString("name", "john")
                .asObject(RequestCapture.class)
                .getBody()
                .assertParam("name", "ringo")
                .assertParam("name", "paul")
                .assertParam("name", "john");
    }

    @Test
    public void testGetUTF8() {
        Unirest.get(MockServer.GET)
                .queryString("param3", "こんにちは")
                .asObject(RequestCapture.class)
                .getBody()
                .assertParam("param3", "こんにちは");
    }

    @Test
    public void testGetMultiple() {
        for (int i = 1; i <= 20; i++) {
            HttpResponse<JsonNode> response = Unirest.get(MockServer.GET + "?try=" + i).asJson();
            parse(response).assertParam("try", String.valueOf(i));
        }
    }

    @Test
    public void testQueryStringEncoding() {
        String testKey = "email2=someKey&email";
        String testValue = "hello@hello.com";

        Unirest.get(MockServer.GET)
                .queryString(testKey, testValue)
                .asObject(RequestCapture.class)
                .getBody()
                .assertParam(testKey, testValue);
    }

    @Test
    public void testGetQuerystringArray() {
        Unirest.get(MockServer.GET)
                .queryString("name", "Mark")
                .queryString("name", "Tom")
                .asObject(RequestCapture.class)
                .getBody()
                .assertParam("name", "Mark")
                .assertParam("name", "Tom");
    }

    @Test
    public void testGetArray() {
        Unirest.get(MockServer.GET)
                .queryString("name", Arrays.asList("Mark", "Tom"))
                .asObject(RequestCapture.class)
                .getBody()
                .assertParam("name", "Mark")
                .assertParam("name", "Tom");
    }
}

@@ -2304,32 +2304,309 @@
 mark2%22);%0A    %7D%0A%0A
+    @Test%0A    public void canPassInACharSequence() %7B%0A        Unirest.get(MockServer.GET)%0A                .queryString(%22foo%22, new StringBuilder(%22bar%22))%0A                .asObject(RequestCapture.class)%0A                .getBody()%0A                .assertParam(%22foo%22, %22bar%22);%0A    %7D%0A%0A
     @Test%0A    pu

add a test for other varients of CharSequence as params