Search in sources :

Example 1 with Endpoint

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

the class DefaultEndpointMetadataTest method queryParameters.

@Test
void queryParameters() throws Exception {
    Endpoint endpoint = endpointMetadata.endpoint(WithQueryParameters.class, WithQueryParameters.class.getMethod("query"));
    URI path = endpoint.path().expand().unsafe();
    assertAll(() -> assertNotNull(endpoint), () -> assertThat(path.toString(), startsWith("http://my.api.com/query")), () -> assertThat(path.getQuery(), allOf(containsString("param1=value1"), containsString("param2=value2"), containsString("param3=value3"), containsString("param4=value4"))), () -> assertThat(endpoint.headers(), emptyIterable()), () -> assertThat(endpoint.cookies(), emptyIterable()), () -> assertThat(endpoint.parameters(), emptyIterable()), () -> assertEquals("GET", endpoint.method()));
}
Also used : Endpoint(com.github.ljtfreitas.julian.Endpoint) URI(java.net.URI) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with Endpoint

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

the class DefaultEndpointMetadataTest method headers.

@Test
void headers() throws Exception {
    Endpoint endpoint = endpointMetadata.endpoint(WithHeaders.class, WithHeaders.class.getMethod("headers"));
    assertAll(() -> assertNotNull(endpoint), () -> assertEquals(URI.create("http://my.api.com/headers"), endpoint.path().expand().unsafe()), () -> assertThat(endpoint.headers(), containsInAnyOrder(new com.github.ljtfreitas.julian.Header("X-Header-1", "x-header-1"), new com.github.ljtfreitas.julian.Header("X-Header-2", "x-header-2"), new com.github.ljtfreitas.julian.Header("X-Header-3", "x-header-3"), new com.github.ljtfreitas.julian.Header("X-Header-4", "x-header-4"))), () -> assertThat(endpoint.cookies(), emptyIterable()), () -> assertThat(endpoint.parameters(), emptyIterable()), () -> assertEquals("GET", endpoint.method()));
}
Also used : Endpoint(com.github.ljtfreitas.julian.Endpoint) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with Endpoint

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

the class DefaultEndpointMetadataTest method cookies.

@Test
void cookies() throws Exception {
    Endpoint endpoint = endpointMetadata.endpoint(WithCookies.class, WithCookies.class.getMethod("cookies"));
    assertAll(() -> assertNotNull(endpoint), () -> assertEquals(URI.create("http://my.api.com/headers"), endpoint.path().expand().unsafe()), () -> assertThat(endpoint.headers(), emptyIterable()), () -> assertThat(endpoint.cookies(), containsInAnyOrder(new com.github.ljtfreitas.julian.Cookie("some-cookie-1", "cookie-1"), new com.github.ljtfreitas.julian.Cookie("some-cookie-2", "cookie-2"), new com.github.ljtfreitas.julian.Cookie("some-cookie-3", "cookie-3"), new com.github.ljtfreitas.julian.Cookie("some-cookie-4", "cookie-4"))), () -> assertThat(endpoint.parameters(), emptyIterable()), () -> assertEquals("GET", endpoint.method()));
}
Also used : Endpoint(com.github.ljtfreitas.julian.Endpoint) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Endpoint (com.github.ljtfreitas.julian.Endpoint)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 URI (java.net.URI)1