use of com.hotels.styx.AggregateRequestBodyExamplePlugin.Config in project styx by ExpediaGroup.
the class AggregateRequestBodyExamplePluginTest method contentIsModified.
@Test
public void contentIsModified() {
// Set up
Config config = new Config("MyExtraText");
String originalBody = "OriginalBody";
AggregateRequestBodyExamplePlugin plugin = new AggregateRequestBodyExamplePlugin(config);
LiveHttpRequest request = LiveHttpRequest.post("/", ByteStream.from(originalBody, UTF_8)).build();
// Our implementation of "chain.proceed()" verifies the content of the request
HttpInterceptor.Chain chain = intRequest -> {
String requestBody = Mono.from(intRequest.aggregate(100)).block().bodyAs(UTF_8);
assertThat(requestBody, is(originalBody + config.extraText()));
return Eventual.of(LiveHttpResponse.response().build());
};
// Invoke plugin and wait until it finishes execution
Mono.from(plugin.intercept(request, chain)).block();
}
Aggregations