Search in sources :

Example 26 with Pair

use of com.github.mjeanroy.junit.servers.utils.commons.Pair in project junit-servers by mjeanroy.

the class BaseHttpClientTest method testPreparePutWithBody.

@Test
void testPreparePutWithBody() {
    final String endpoint = ENDPOINT + "/1";
    final int status = 204;
    final Collection<Pair> headers = emptyList();
    final String body = "{\"id\": 1, \"name\": \"Jane Doe\"}";
    stubPutRequest(endpoint, status, headers);
    final HttpResponse rsp = createDefaultClient().preparePut(endpoint, jsonBody(body)).execute();
    assertRequest(endpoint, HttpMethod.PUT);
    assertThat(rsp.status()).isEqualTo(status);
    assertThat(rsp.body()).isEmpty();
    assertThat(rsp.getContentType()).isNull();
}
Also used : HttpResponse(com.github.mjeanroy.junit.servers.client.HttpResponse) Pair(com.github.mjeanroy.junit.servers.utils.commons.Pair) WireMockTest(com.github.mjeanroy.junit.servers.utils.jupiter.WireMockTest) Test(org.junit.jupiter.api.Test)

Example 27 with Pair

use of com.github.mjeanroy.junit.servers.utils.commons.Pair in project junit-servers by mjeanroy.

the class BaseHttpClientTest method testPreparePatchWithBody.

@Test
void testPreparePatchWithBody() {
    final String endpoint = ENDPOINT + "/1";
    final int status = 204;
    final Collection<Pair> headers = emptyList();
    final String body = "{\"id\": 1, \"name\": \"Jane Doe\"}";
    stubPatchRequest(endpoint, status, headers, body);
    final HttpResponse rsp = createDefaultClient().preparePatch(endpoint, jsonBody(body)).execute();
    assertRequest(endpoint, HttpMethod.PATCH);
    assertThat(rsp.status()).isEqualTo(status);
    assertThat(rsp.body()).isEmpty();
}
Also used : HttpResponse(com.github.mjeanroy.junit.servers.client.HttpResponse) Pair(com.github.mjeanroy.junit.servers.utils.commons.Pair) WireMockTest(com.github.mjeanroy.junit.servers.utils.jupiter.WireMockTest) Test(org.junit.jupiter.api.Test)

Aggregations

Pair (com.github.mjeanroy.junit.servers.utils.commons.Pair)27 HttpResponse (com.github.mjeanroy.junit.servers.client.HttpResponse)25 WireMockTest (com.github.mjeanroy.junit.servers.utils.jupiter.WireMockTest)20 Test (org.junit.jupiter.api.Test)20 HttpRequestBody (com.github.mjeanroy.junit.servers.client.HttpRequestBody)4 HttpRequest (com.github.mjeanroy.junit.servers.client.HttpRequest)3 HttpHeader (com.github.mjeanroy.junit.servers.client.HttpHeader)2 UrlPattern (com.github.tomakehurst.wiremock.matching.UrlPattern)2 Cookie (com.github.mjeanroy.junit.servers.client.Cookie)1 WireMockTestUtils.assertRequestWithCookie (com.github.mjeanroy.junit.servers.client.it.WireMockTestUtils.assertRequestWithCookie)1 MappingBuilder (com.github.tomakehurst.wiremock.client.MappingBuilder)1 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)1 HttpHeader (com.github.tomakehurst.wiremock.http.HttpHeader)1 HttpHeaders (com.github.tomakehurst.wiremock.http.HttpHeaders)1 RequestMethod (com.github.tomakehurst.wiremock.http.RequestMethod)1 RequestPatternBuilder (com.github.tomakehurst.wiremock.matching.RequestPatternBuilder)1