@Test public void contentIsModified() { Config config = new Config("MyExtraText"); String originalBody = "OriginalBody"; AggregateRequestBodyExamplePlugin plugin = new AggregateRequestBodyExamplePlugin(config); LiveHttpRequest request = LiveHttpRequest.post("/", ByteStream.from(originalBody, UTF_8)).build(); 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()); }; Mono.from(plugin.intercept(request, chain)).block(); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .build().stream(); }).flatMap(chain::proceed); }
AggregateRequestBodyExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .build().stream(); }).flatMap(chain::proceed); } }
AggregateRequestBodyExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .build().stream(); }).flatMap(chain::proceed); } AggregateRequestBodyExamplePlugin(Config config); }
AggregateRequestBodyExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .build().stream(); }).flatMap(chain::proceed); } AggregateRequestBodyExamplePlugin(Config config); @Override Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain); }
AggregateRequestBodyExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .build().stream(); }).flatMap(chain::proceed); } AggregateRequestBodyExamplePlugin(Config config); @Override Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain);  }