use of org.mule.runtime.http.api.domain.entity.ByteArrayHttpEntity in project mule by mulesoft.
the class HttpResponseBuilderTestCase method complexResponse.
@Test
public void complexResponse() {
HttpResponse response = builder.entity(new ByteArrayHttpEntity("test".getBytes())).statusCode(418).reasonPhrase("I'm a teapot").addHeader(header, value).build();
assertThat(response.getStatusCode(), is(418));
assertThat(response.getReasonPhrase(), is("I'm a teapot"));
assertThat(response.getEntity(), is(instanceOf(ByteArrayHttpEntity.class)));
assertThat(response.getHeaderNames(), hasItems(equalToIgnoringCase(header)));
assertThat(response.getHeaderValuesIgnoreCase(header), hasItems(value));
}
use of org.mule.runtime.http.api.domain.entity.ByteArrayHttpEntity in project mule by mulesoft.
the class HttpRequestBuilderTestCase method complexResponse.
@Test
public void complexResponse() {
MultiMap<String, String> paramMap = new MultiMap<>();
paramMap.put(name, value);
HttpRequest request = builder.entity(new ByteArrayHttpEntity("test".getBytes())).uri(URI_VALUE).method(POST).queryParams(paramMap).headers(paramMap).addHeader(name.toUpperCase(), value.toUpperCase()).build();
assertThat(request.getUri(), is(URI.create(URI_VALUE)));
assertThat(request.getMethod(), is(POST.name()));
assertThat(request.getEntity(), is(instanceOf(ByteArrayHttpEntity.class)));
assertThat(request.getHeaderNames(), hasItems(name));
assertThat(request.getHeaderValues(name), hasItems(value, value.toUpperCase()));
MultiMap<String, String> requestQueryParams = request.getQueryParams();
assertThat(requestQueryParams.keySet(), hasItems(name));
assertThat(requestQueryParams.getAll(name), hasItems(value));
}
Aggregations