use of com.palantir.dialogue.UrlBuilder in project conjure-java-runtime by palantir.
the class JaxRsClientDialogueEndpointTest method testSlashPathParameter.
@Test
public void testSlashPathParameter() {
Channel channel = stubNoContentResponseChannel();
StubService service = JaxRsClient.create(StubService.class, channel, runtime);
service.innerPath("/");
ArgumentCaptor<Endpoint> endpointCaptor = ArgumentCaptor.forClass(Endpoint.class);
ArgumentCaptor<Request> requestCaptor = ArgumentCaptor.forClass(Request.class);
verify(channel).execute(endpointCaptor.capture(), requestCaptor.capture());
UrlBuilder urlBuilder = mock(UrlBuilder.class);
endpointCaptor.getValue().renderPath(ImmutableMap.of(), urlBuilder);
// context path
verify(urlBuilder).pathSegment("foo");
// encoded into %2F by DefaultUrlBuilder
verify(urlBuilder).pathSegment("/");
}
use of com.palantir.dialogue.UrlBuilder in project conjure-java-runtime by palantir.
the class JaxRsClientDialogueEndpointTest method testTrailingWildcardParameter_slashes.
@Test
public void testTrailingWildcardParameter_slashes() {
Channel channel = stubNoContentResponseChannel();
StubService service = JaxRsClient.create(StubService.class, channel, runtime);
service.complexPath("dynamic0", "dynamic1/dynamic2");
ArgumentCaptor<Endpoint> endpointCaptor = ArgumentCaptor.forClass(Endpoint.class);
ArgumentCaptor<Request> requestCaptor = ArgumentCaptor.forClass(Request.class);
verify(channel).execute(endpointCaptor.capture(), requestCaptor.capture());
UrlBuilder urlBuilder = mock(UrlBuilder.class);
endpointCaptor.getValue().renderPath(ImmutableMap.of(), urlBuilder);
// context path
verify(urlBuilder).pathSegment("foo");
verify(urlBuilder).pathSegment("static0");
verify(urlBuilder).pathSegment("dynamic0");
verify(urlBuilder).pathSegment("static1");
// Value should not be split into multiple segments
verify(urlBuilder).pathSegment("dynamic1/dynamic2");
}
use of com.palantir.dialogue.UrlBuilder in project conjure-java-runtime by palantir.
the class JaxRsClientDialogueEndpointTest method testQueryParameterCollection.
@Test
public void testQueryParameterCollection() {
Channel channel = stubNoContentResponseChannel();
StubService service = JaxRsClient.create(StubService.class, channel, runtime);
service.collectionOfQueryParams(ImmutableList.of("a", "/", "", "a b", "a+b"));
ArgumentCaptor<Endpoint> endpointCaptor = ArgumentCaptor.forClass(Endpoint.class);
ArgumentCaptor<Request> requestCaptor = ArgumentCaptor.forClass(Request.class);
verify(channel).execute(endpointCaptor.capture(), requestCaptor.capture());
UrlBuilder urlBuilder = mock(UrlBuilder.class);
endpointCaptor.getValue().renderPath(ImmutableMap.of(), urlBuilder);
verify(urlBuilder).queryParam("query", "a");
verify(urlBuilder).queryParam("query", "/");
verify(urlBuilder).queryParam("query", "");
verify(urlBuilder).queryParam("query", "a b");
verify(urlBuilder).queryParam("query", "a+b");
}
use of com.palantir.dialogue.UrlBuilder in project conjure-java-runtime by palantir.
the class JaxRsClientDialogueEndpointTest method testTrailingWildcardParameter_emptyString.
@Test
public void testTrailingWildcardParameter_emptyString() {
Channel channel = stubNoContentResponseChannel();
StubService service = JaxRsClient.create(StubService.class, channel, runtime);
service.complexPath("dynamic0", "");
ArgumentCaptor<Endpoint> endpointCaptor = ArgumentCaptor.forClass(Endpoint.class);
ArgumentCaptor<Request> requestCaptor = ArgumentCaptor.forClass(Request.class);
verify(channel).execute(endpointCaptor.capture(), requestCaptor.capture());
UrlBuilder urlBuilder = mock(UrlBuilder.class);
endpointCaptor.getValue().renderPath(ImmutableMap.of(), urlBuilder);
// context path
verify(urlBuilder).pathSegment("foo");
verify(urlBuilder).pathSegment("static0");
verify(urlBuilder).pathSegment("dynamic0");
verify(urlBuilder).pathSegment("static1");
// Empty string must be included
verify(urlBuilder).pathSegment("");
}
use of com.palantir.dialogue.UrlBuilder in project conjure-java-runtime by palantir.
the class JaxRsClientDialogueEndpointTest method testEmptyStringPathParameter.
@Test
public void testEmptyStringPathParameter() {
Channel channel = stubNoContentResponseChannel();
StubService service = JaxRsClient.create(StubService.class, channel, runtime);
service.innerPath("");
ArgumentCaptor<Endpoint> endpointCaptor = ArgumentCaptor.forClass(Endpoint.class);
ArgumentCaptor<Request> requestCaptor = ArgumentCaptor.forClass(Request.class);
verify(channel).execute(endpointCaptor.capture(), requestCaptor.capture());
UrlBuilder urlBuilder = mock(UrlBuilder.class);
endpointCaptor.getValue().renderPath(ImmutableMap.of(), urlBuilder);
// context path
verify(urlBuilder).pathSegment("foo");
verify(urlBuilder).pathSegment("begin");
verify(urlBuilder).pathSegment("");
verify(urlBuilder).pathSegment("end");
}
Aggregations