use of com.palantir.dialogue.BodySerDe in project dialogue by palantir.
the class ConjureBodySerDeTest method testEmptyResponse_list_raw.
@Test
@SuppressWarnings("rawtypes")
public void testEmptyResponse_list_raw() {
BodySerDe serde = DefaultConjureRuntime.builder().build().bodySerDe();
List result = serde.deserializer(new TypeMarker<List>() {
}).deserialize(new TestResponse().code(204));
assertThat(result).isEmpty();
}
use of com.palantir.dialogue.BodySerDe in project dialogue by palantir.
the class ConjureBodySerDeTest method testRepeatableBinaryRequestBodyProducesRepeatableRequest.
@Test
public void testRepeatableBinaryRequestBodyProducesRepeatableRequest() {
BodySerDe serde = DefaultConjureRuntime.builder().build().bodySerDe();
RequestBody requestBody = serde.serialize(new BinaryRequestBody() {
@Override
public void write(OutputStream _requestBody) {
}
@Override
public boolean repeatable() {
return true;
}
});
assertThat(requestBody.repeatable()).isTrue();
}
use of com.palantir.dialogue.BodySerDe in project dialogue by palantir.
the class ConjureBodySerDeTest method testNonRepeatableBinaryRequestBodyProducesNonRepeatableRequest.
@Test
public void testNonRepeatableBinaryRequestBodyProducesNonRepeatableRequest() {
BodySerDe serde = DefaultConjureRuntime.builder().build().bodySerDe();
RequestBody requestBody = serde.serialize(new BinaryRequestBody() {
@Override
public void write(OutputStream _requestBody) {
}
@Override
public boolean repeatable() {
return false;
}
});
assertThat(requestBody.repeatable()).isFalse();
}
use of com.palantir.dialogue.BodySerDe in project dialogue by palantir.
the class ConjureBodySerDeTest method testDefaultContentType.
@Test
public void testDefaultContentType() throws IOException {
BodySerDe serializers = conjureBodySerDe("text/plain", "application/json");
// first encoding is default
RequestBody body = serializers.serializer(TYPE).serialize("test");
assertThat(body.contentType()).isEqualTo("text/plain");
assertThat(serializers.deserializer(TYPE).accepts()).hasValue("text/plain, application/json");
}
use of com.palantir.dialogue.BodySerDe in project dialogue by palantir.
the class ConjureBodySerDeTest method testRequestUnknownContentType.
@Test
public void testRequestUnknownContentType() throws IOException {
BodySerDe serializers = conjureBodySerDe("application/json", "text/plain");
RequestBody body = serializers.serializer(TYPE).serialize("test");
assertThat(body.contentType()).isEqualTo("application/json");
}
Aggregations