use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class VersionTextHandlerTest method canCombineVersionTextFiles.
@Test
public void canCombineVersionTextFiles() {
VersionTextHandler handler = new VersionTextHandler(resources("classpath:/versions/version1.txt", "classpath:/versions/version2.txt"));
HttpResponse response = Mono.from(handler.handle(get("/version.txt").build(), requestContext())).block();
assertThat(response.bodyAs(UTF_8), is("foo\nbar\n"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class OriginsCommandHandlerTest method failsToIssueTheCommandForNonexistentAppId.
@ParameterizedTest
@MethodSource("nonexistentAppOrOriginId")
public void failsToIssueTheCommandForNonexistentAppId(String appId) {
HttpResponse response = post(format("/admin/tasks/origins?cmd=disable_origin&appId=%s&originId=bar", appId));
assertThat(response.status(), is(BAD_REQUEST));
assertThat(response.bodyAs(UTF_8), is(format("application with id=%s is not found", appId)));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class OriginsCommandHandlerTest method returnsProperErrorMessageForMissingOriginId.
@Test
public void returnsProperErrorMessageForMissingOriginId() {
HttpResponse response = post("/admin/tasks/origins?cmd=disable_origin&appId=foo");
assertThat(response.status(), is(BAD_REQUEST));
assertThat(response.bodyAs(UTF_8), is("cmd, appId and originId are all required parameters. cmd can be enable_origin|disable_origin"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class OriginsCommandHandlerTest method failsToIssueTheCommandForNonexistentOriginId.
@ParameterizedTest
@MethodSource("nonexistentAppOrOriginId")
public void failsToIssueTheCommandForNonexistentOriginId(String originId) {
HttpResponse response = post(format("/admin/tasks/origins?cmd=disable_origin&appId=activeAppId&originId=%s", originId));
assertThat(response.status(), is(BAD_REQUEST));
assertThat(response.bodyAs(UTF_8), is(format("origin with id=%s is not found for application=activeAppId", originId)));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class OriginsReloadCommandHandlerTest method returnsWithInformationWhenErrorDuringReload.
@Test
public void returnsWithInformationWhenErrorDuringReload() {
mockRegistryReload(failedFuture(new RuntimeException(new RuntimeException("simulated error"))));
HttpResponse response = Mono.from(handler.handle(get("/").build(), mock(HttpInterceptor.Context.class))).block();
assertThat(response.status(), is(INTERNAL_SERVER_ERROR));
assertThat(response.bodyAs(UTF_8), is(matchesRegex("There was an error processing your request. It has been logged \\(ID [0-9a-f-]+\\)\\.\n")));
}
Aggregations