use of com.palantir.dialogue.Request in project dialogue by palantir.
the class ContentEncodingChannelTest method testNoBody.
@Test
void testNoBody() {
Request request = Request.builder().build();
Request wrapped = ContentEncodingChannel.wrap(request);
assertThat(wrapped).isSameAs(request);
}
use of com.palantir.dialogue.Request in project dialogue by palantir.
the class ContentEncodingChannelTest method testContentLengthExistsOutsideBody.
@Test
void testContentLengthExistsOutsideBody() {
// This case shouldn't be supported in any way, however
// it's best to handle unexpected cases gracefully.
Request request = Request.builder().putHeaderParams("Content-Length", "123").body(StubBody.INSTANCE).build();
Request wrapped = ContentEncodingChannel.wrap(request);
assertThat(wrapped).isSameAs(request);
}
use of com.palantir.dialogue.Request in project dialogue by palantir.
the class ContentEncodingChannelTest method testContentEncodingExists.
@Test
void testContentEncodingExists() {
Request request = Request.builder().putHeaderParams("Content-Encoding", "identity").body(StubBody.INSTANCE).build();
Request wrapped = ContentEncodingChannel.wrap(request);
assertThat(wrapped).isSameAs(request);
}
use of com.palantir.dialogue.Request in project dialogue by palantir.
the class DialogueChannelTest method createRequestWithAddExecutedOnAttachment.
private Request createRequestWithAddExecutedOnAttachment() {
Request newRequest = Request.builder().build();
StickyAttachments.requestStickyToken(newRequest);
return newRequest;
}
use of com.palantir.dialogue.Request in project dialogue by palantir.
the class DialogueChannelTest method bad_channel_throwing_an_exception_still_returns_a_future.
@Test
public void bad_channel_throwing_an_exception_still_returns_a_future() {
Channel badUserImplementation = new Channel() {
@Override
public ListenableFuture<Response> execute(Endpoint _endpoint, Request _request) {
throw new IllegalStateException("Always throw");
}
};
channel = DialogueChannel.builder().channelName("my-channel").clientConfiguration(stubConfig).factory(_args -> badUserImplementation).build();
// this should never throw
ListenableFuture<Response> future = channel.execute(endpoint, request);
// only when we access things do we allow exceptions
assertThatThrownBy(() -> Futures.getUnchecked(future)).hasCauseInstanceOf(IllegalStateException.class);
}
Aggregations