Search in sources :

Example 6 with UrlBuilder

use of com.palantir.dialogue.UrlBuilder in project dialogue by palantir.

the class UserAgentEndpointChannelTest method testServiceNameIsNotValidConjureAgent.

@Test
public void testServiceNameIsNotValidConjureAgent() {
    EndpointChannel channel = UserAgentEndpointChannel.create(delegate, new Endpoint() {

        @Override
        public void renderPath(Map<String, String> _params, UrlBuilder _url) {
        }

        @Override
        public HttpMethod httpMethod() {
            return HttpMethod.GET;
        }

        @Override
        public String serviceName() {
            return "Service_Name";
        }

        @Override
        public String endpointName() {
            return "endpoint";
        }

        @Override
        public String version() {
            return "4.5.6";
        }
    }, baseAgent);
    // Special case: In IDEs, tests are run against classes (not JARs) and thus don't carry versions.
    String dialogueVersion = Optional.ofNullable(Channel.class.getPackage().getImplementationVersion()).orElse("0.0.0");
    channel.execute(request);
    verify(delegate).execute(requestCaptor.capture());
    assertThat(requestCaptor.getValue().headerParams().get("user-agent")).containsExactly("test-class/1.2.3 dialogue/" + dialogueVersion);
}
Also used : TestEndpoint(com.palantir.dialogue.TestEndpoint) Endpoint(com.palantir.dialogue.Endpoint) Channel(com.palantir.dialogue.Channel) EndpointChannel(com.palantir.dialogue.EndpointChannel) EndpointChannel(com.palantir.dialogue.EndpointChannel) UrlBuilder(com.palantir.dialogue.UrlBuilder) HttpMethod(com.palantir.dialogue.HttpMethod) Test(org.junit.jupiter.api.Test)

Aggregations

Channel (com.palantir.dialogue.Channel)6 Endpoint (com.palantir.dialogue.Endpoint)6 UrlBuilder (com.palantir.dialogue.UrlBuilder)6 Request (com.palantir.dialogue.Request)5 Test (org.junit.Test)5 EndpointChannel (com.palantir.dialogue.EndpointChannel)1 HttpMethod (com.palantir.dialogue.HttpMethod)1 TestEndpoint (com.palantir.dialogue.TestEndpoint)1 Test (org.junit.jupiter.api.Test)1