Search in sources :

Example 11 with RequestEntity

use of com.tvd12.ezyhttp.client.request.RequestEntity in project ezyhttp by youngmonkeys.

the class RequestEntityTest method buildWithBodyNull.

@Test
public void buildWithBodyNull() {
    // given
    RequestEntity sut = RequestEntity.builder().body(null).build();
    // when
    // then
    Asserts.assertNull(sut.getHeader("unknown"));
    Asserts.assertEquals(ContentTypes.APPLICATION_JSON, sut.getContentType());
    System.out.println(sut);
}
Also used : RequestEntity(com.tvd12.ezyhttp.client.request.RequestEntity) Test(org.testng.annotations.Test)

Example 12 with RequestEntity

use of com.tvd12.ezyhttp.client.request.RequestEntity in project ezyhttp by youngmonkeys.

the class RequestEntityTest method createByHeadersAndBody.

@Test
public void createByHeadersAndBody() {
    // given
    Map<String, List<String>> headers = new HashMap<>();
    String body = RandomUtil.randomShortAlphabetString();
    // when
    RequestEntity sut = new RequestEntity(headers, body);
    // then
    Asserts.assertEquals(new MultiValueMap(headers), sut.getHeaders());
    Asserts.assertEquals(body, sut.getBody());
}
Also used : RequestEntity(com.tvd12.ezyhttp.client.request.RequestEntity) MultiValueMap(com.tvd12.ezyhttp.core.data.MultiValueMap) Test(org.testng.annotations.Test)

Aggregations

RequestEntity (com.tvd12.ezyhttp.client.request.RequestEntity)10 Test (org.testng.annotations.Test)5 HttpClient (com.tvd12.ezyhttp.client.HttpClient)4 MultiValueMap (com.tvd12.ezyhttp.core.data.MultiValueMap)4 PostRequest (com.tvd12.ezyhttp.client.request.PostRequest)3 GetRequest (com.tvd12.ezyhttp.client.request.GetRequest)2 Request (com.tvd12.ezyhttp.client.request.Request)2 HelloRequest (com.tvd12.ezyhttp.client.test.request.HelloRequest)2 HttpClientProxy (com.tvd12.ezyhttp.client.HttpClientProxy)1 Customer (com.tvd12.ezyhttp.client.test.request.Customer)1 ResponseEntity (com.tvd12.ezyhttp.core.response.ResponseEntity)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 User (org.youngmonkeys.example.ezyhttp.website.user_management.entity.User)1