Search in sources :

Example 1 with HTTPResponse

use of com.github.ljtfreitas.julian.http.HTTPResponse in project julian-http-client by ljtfreitas.

the class HeadersResponseTTest method compose.

@Test
void compose(@Mock ResponseFn<Void, Void> fn, @Mock HTTPResponse<Void> response) {
    Arguments arguments = Arguments.empty();
    Headers headers = Headers.create(new Header("X-Header", "x-header-content"));
    when(response.headers()).thenReturn(headers.all().stream().reduce(HTTPHeaders.empty(), (a, b) -> a.join(new HTTPHeader(b.name(), b.values())), (a, b) -> b));
    when(response.cast(notNull())).thenCallRealMethod();
    Headers actual = responseT.bind(endpoint, fn).join(Promise.done(response), arguments);
    assertThat(actual, contains(headers.all().toArray()));
}
Also used : MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Mock(org.mockito.Mock) Mockito.when(org.mockito.Mockito.when) Nested(org.junit.jupiter.api.Nested) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) HTTPHeader(com.github.ljtfreitas.julian.http.HTTPHeader) HTTPHeaders(com.github.ljtfreitas.julian.http.HTTPHeaders) HTTPResponse(com.github.ljtfreitas.julian.http.HTTPResponse) Matchers.contains(org.hamcrest.Matchers.contains) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ArgumentMatchers.notNull(org.mockito.ArgumentMatchers.notNull) HTTPHeader(com.github.ljtfreitas.julian.http.HTTPHeader) HTTPHeaders(com.github.ljtfreitas.julian.http.HTTPHeaders) HTTPHeader(com.github.ljtfreitas.julian.http.HTTPHeader) Test(org.junit.jupiter.api.Test)

Aggregations

HTTPHeader (com.github.ljtfreitas.julian.http.HTTPHeader)1 HTTPHeaders (com.github.ljtfreitas.julian.http.HTTPHeaders)1 HTTPResponse (com.github.ljtfreitas.julian.http.HTTPResponse)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 Nested (org.junit.jupiter.api.Nested)1 Test (org.junit.jupiter.api.Test)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 ArgumentMatchers.notNull (org.mockito.ArgumentMatchers.notNull)1 Mock (org.mockito.Mock)1 Mockito.when (org.mockito.Mockito.when)1 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)1