Search in sources :

Example 1 with Config

use of com.hotels.styx.ModifyContentByAggregationExamplePlugin.Config in project styx by ExpediaGroup.

the class ModifyContentByAggregationExamplePluginTest method modifiesContent.

@Test
public void modifiesContent() {
    // Set up
    Config config = new Config("MyExtraText");
    ModifyContentByAggregationExamplePlugin plugin = new ModifyContentByAggregationExamplePlugin(config);
    LiveHttpRequest request = get("/").build();
    HttpInterceptor.Chain chain = anyRequest -> Eventual.of(response().body("OriginalBody", UTF_8).build().stream());
    // Execution
    HttpResponse response = Mono.from(plugin.intercept(request, chain).flatMap(liveResponse -> liveResponse.aggregate(100))).block();
    // Assertion
    assertThat(response.bodyAs(UTF_8), is("OriginalBodyMyExtraText"));
}
Also used : HttpInterceptor(com.hotels.styx.api.HttpInterceptor) Test(org.junit.jupiter.api.Test) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Eventual(com.hotels.styx.api.Eventual) HttpResponse(com.hotels.styx.api.HttpResponse) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Config(com.hotels.styx.ModifyContentByAggregationExamplePlugin.Config) HttpResponse.response(com.hotels.styx.api.HttpResponse.response) LiveHttpRequest.get(com.hotels.styx.api.LiveHttpRequest.get) Mono(reactor.core.publisher.Mono) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) LiveHttpRequest(com.hotels.styx.api.LiveHttpRequest) Config(com.hotels.styx.ModifyContentByAggregationExamplePlugin.Config) LiveHttpRequest(com.hotels.styx.api.LiveHttpRequest) HttpInterceptor(com.hotels.styx.api.HttpInterceptor) HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test)

Aggregations

Config (com.hotels.styx.ModifyContentByAggregationExamplePlugin.Config)1 Eventual (com.hotels.styx.api.Eventual)1 HttpInterceptor (com.hotels.styx.api.HttpInterceptor)1 HttpResponse (com.hotels.styx.api.HttpResponse)1 HttpResponse.response (com.hotels.styx.api.HttpResponse.response)1 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)1 LiveHttpRequest.get (com.hotels.styx.api.LiveHttpRequest.get)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Test (org.junit.jupiter.api.Test)1 Mono (reactor.core.publisher.Mono)1