use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method disablesEnabledPlugin.
@Test
public void disablesEnabledPlugin() {
HttpRequest request = put("/foo/on/enabled").body("false", UTF_8).build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(body(response), is("{\"message\":\"State of 'on' changed to 'disabled'\",\"plugin\":{\"name\":\"on\",\"state\":\"disabled\"}}"));
assertThat(initiallyEnabled.enabled(), is(false));
assertThat(initiallyDisabled.enabled(), is(false));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method saysBadRequestWhenNoStateSpecified.
@Test
public void saysBadRequestWhenNoStateSpecified() {
HttpRequest request = put("/foo/on/enabled").build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(BAD_REQUEST));
assertThat(body(response), is("No such state: only 'true' and 'false' are valid."));
assertThat(initiallyEnabled.enabled(), is(true));
assertThat(initiallyDisabled.enabled(), is(false));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method enablesDisabledPlugin.
@Test
public void enablesDisabledPlugin() {
HttpRequest request = put("/foo/off/enabled").body("true", UTF_8).build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(body(response), is("{\"message\":\"State of 'off' changed to 'enabled'\",\"plugin\":{\"name\":\"off\",\"state\":\"enabled\"}}"));
assertThat(initiallyEnabled.enabled(), is(true));
assertThat(initiallyDisabled.enabled(), is(true));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method notifiesWhenPluginAlreadyEnabled.
@Test
public void notifiesWhenPluginAlreadyEnabled() {
HttpRequest request = put("/foo/on/enabled").body("true", UTF_8).build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(body(response), is("{\"message\":\"State of 'on' was already 'enabled'\",\"plugin\":{\"name\":\"on\",\"state\":\"enabled\"}}"));
assertThat(initiallyEnabled.enabled(), is(true));
assertThat(initiallyDisabled.enabled(), is(false));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method saysBadRequestWhenUrlIsInvalid.
@Test
public void saysBadRequestWhenUrlIsInvalid() {
HttpRequest request = put("/foo//enabled").body("true", UTF_8).build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(BAD_REQUEST));
assertThat(body(response), is("Invalid URL"));
assertThat(initiallyEnabled.enabled(), is(true));
assertThat(initiallyDisabled.enabled(), is(false));
}
Aggregations