Search in sources :

Example 11 with MultiValueMap

use of com.tvd12.ezyhttp.core.data.MultiValueMap in project ezyhttp by youngmonkeys.

the class MultiValueMapTest method getValueMapTest.

@Test
public void getValueMapTest() {
    // given
    Map<String, Object> values = new HashMap<>();
    values.put("a", null);
    values.put("b", "");
    values.put("c", 100);
    values.put("d", "good");
    values.put("e", true);
    MultiValueMap sut = MultiValueMap.builder().setValue("1", "hello").setValues("2", Arrays.asList("foo", "bar")).setValues("3", Collections.emptyList()).setValues("m", values).setValue("z", "").build();
    // when
    Map<String, String> actual1 = sut.getValueMap("m");
    Map<String, String> actual2 = sut.getValueMap("1");
    Map<String, String> actual3 = sut.getValueMap("2");
    Map<String, String> actual4 = sut.getValueMap("z");
    // then
    Map<String, Object> expectation1 = new HashMap<>();
    expectation1.put("a", null);
    expectation1.put("b", "");
    expectation1.put("c", "100");
    expectation1.put("d", "good");
    expectation1.put("e", "true");
    Asserts.assertEquals(actual1, expectation1);
    Map<String, String> expectation2 = new HashMap<>();
    expectation2.put("hello", null);
    Asserts.assertEquals(actual2, expectation2);
    Map<String, String> expectation3 = new HashMap<>();
    expectation3.put("foo", null);
    expectation3.put("bar", null);
    Asserts.assertEquals(actual3, expectation3);
    Asserts.assertEquals(new HashMap<>(), actual4);
}
Also used : HashMap(java.util.HashMap) MultiValueMap(com.tvd12.ezyhttp.core.data.MultiValueMap) Test(org.testng.annotations.Test)

Aggregations

MultiValueMap (com.tvd12.ezyhttp.core.data.MultiValueMap)11 Test (org.testng.annotations.Test)8 HashMap (java.util.HashMap)5 RequestEntity (com.tvd12.ezyhttp.client.request.RequestEntity)3 ResponseEntity (com.tvd12.ezyhttp.core.response.ResponseEntity)3 List (java.util.List)3 DownloadRequest (com.tvd12.ezyhttp.client.request.DownloadRequest)1 Redirect (com.tvd12.ezyhttp.server.core.view.Redirect)1 View (com.tvd12.ezyhttp.server.core.view.View)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Cookie (javax.servlet.http.Cookie)1