use of com.hotels.styx.api.plugins.spi.Plugin in project styx by ExpediaGroup.
the class InstrumentedPluginTest method metricIsNotRecordedWhenErrorStatusIsReturnedByChain.
@Test
public void metricIsNotRecordedWhenErrorStatusIsReturnedByChain() {
Chain chain = request -> aResponse(INTERNAL_SERVER_ERROR);
String pluginName = "doNotRecordMe";
InstrumentedPlugin plugin = instrumentedPlugin(pluginName, PASS_THROUGH);
LiveHttpResponse response = Mono.from(plugin.intercept(someRequest, chain)).block();
assertThat(response.status(), is(INTERNAL_SERVER_ERROR));
assertThat(getStatusCount(pluginName, "500"), is(0.0));
assertThat(getErrorCount(pluginName), is(0.0));
}
use of com.hotels.styx.api.plugins.spi.Plugin in project styx by ExpediaGroup.
the class InstrumentedPluginTest method metricIsRecordedWhenResponseIsMappedToErrorStatus.
@Test
public void metricIsRecordedWhenResponseIsMappedToErrorStatus() {
Chain chain = request -> aResponse(OK);
String pluginName = "replaceStatus1";
InstrumentedPlugin plugin = instrumentedPlugin(pluginName, (request, aChain) -> aChain.proceed(request).map(response -> responseWithNewStatusCode(response, INTERNAL_SERVER_ERROR)));
LiveHttpResponse response = Mono.from(plugin.intercept(someRequest, chain)).block();
assertThat(response.status(), is(INTERNAL_SERVER_ERROR));
assertThat(getStatusCount(pluginName, "500"), is(1.0));
assertThat(getErrorCount(pluginName), is(1.0));
}
use of com.hotels.styx.api.plugins.spi.Plugin in project styx by ExpediaGroup.
the class InstrumentedPluginTest method originalPluginShouldBePluginThatIsPassedIn.
@Test
public void originalPluginShouldBePluginThatIsPassedIn() {
Plugin mockPlugin = Mockito.mock(Plugin.class);
InstrumentedPlugin plugin = instrumentedPlugin("pluginName", mockPlugin);
assertThat(plugin.originalPlugin(), is(mockPlugin));
}
use of com.hotels.styx.api.plugins.spi.Plugin in project styx by ExpediaGroup.
the class StyxServerTest method mockPlugin.
private Plugin mockPlugin(Map<String, HttpHandler> adminInterfaceHandlers) {
Plugin plugin = mock(Plugin.class);
when(plugin.adminInterfaceHandlers()).thenReturn(adminInterfaceHandlers);
return plugin;
}
use of com.hotels.styx.api.plugins.spi.Plugin in project styx by ExpediaGroup.
the class StyxServerTest method addsEndpointLinksToPluginPage.
@Test
public void addsEndpointLinksToPluginPage() {
setUpStyxAndPluginWithAdminPages(Map.of("adminPage1", (request, ctx) -> Eventual.of(LiveHttpResponse.response().build()), "adminPage2", (request, ctx) -> Eventual.of(LiveHttpResponse.response().build())));
HttpResponse response = doAdminRequest("/admin/plugins/plugin-with-admin-pages");
assertThat(response.status(), is(OK));
assertThat(response.bodyAs(UTF_8), allOf(containsString("/admin/plugins/plugin-with-admin-pages/adminPage1"), containsString("/admin/plugins/plugin-with-admin-pages/adminPage2")));
}
Aggregations