use of com.hotels.styx.api.HttpResponseStatus.OK in project styx by ExpediaGroup.
the class StandardHttpPipelineTest method interceptorReceivesNewContext.
@Test
public void interceptorReceivesNewContext() {
HttpInterceptor expectNewContext = (request, chain) -> {
Object seen = chain.context().get("seen", Object.class);
assertThat("Old context reused" + seen, seen, is(nullValue()));
chain.context().add("seen", true);
return chain.proceed(request);
};
StandardHttpPipeline pipeline = pipeline(expectNewContext);
assertThat(sendRequestTo(pipeline).status(), is(OK));
// make the same request again to ensure a new context is used
assertThat(sendRequestTo(pipeline).status(), is(OK));
}
use of com.hotels.styx.api.HttpResponseStatus.OK in project styx by ExpediaGroup.
the class InstrumentedPluginTest method errorsMetricIsNotRecordedWhenResponseIsMappedToNon5005xxStatus.
@Test
public void errorsMetricIsNotRecordedWhenResponseIsMappedToNon5005xxStatus() {
Chain chain = request -> aResponse(OK);
String pluginName = "replaceStatusCodeY";
InstrumentedPlugin plugin = instrumentedPlugin("replaceStatusCodeY", (request, aChain) -> aChain.proceed(request).map(response -> responseWithNewStatusCode(response, BAD_GATEWAY)));
LiveHttpResponse response = Mono.from(plugin.intercept(someRequest, chain)).block();
assertThat(response.status(), is(BAD_GATEWAY));
assertThat(getStatusCount(pluginName, "502"), is(1.0));
assertThat(getErrorCount(pluginName), is(0.0));
}
Aggregations