use of com.github.tomakehurst.wiremock.common.Errors in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenContainsOperandIsNull.
@Test
public void returnsBadEntityStatusWhenContainsOperandIsNull() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"bodyPatterns\": [\n" + " {\n" + " \"contains\": null\n" + " }\n" + " ]\n" + " }\n" + "}");
assertThat(response.statusCode(), is(422));
Errors errors = Json.read(response.content(), Errors.class);
assertThat(errors.first().getSource().getPointer(), is("/request/bodyPatterns/0"));
assertThat(errors.first().getTitle(), is("Error parsing JSON"));
assertThat(errors.first().getDetail(), is("contains operand must be a non-null string"));
}
use of com.github.tomakehurst.wiremock.common.Errors in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenInvalidMatchOperatorManyBodyPatterns.
@Test
public void returnsBadEntityStatusWhenInvalidMatchOperatorManyBodyPatterns() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"bodyPatterns\": [\n" + " {\n" + " \"equalTo\": \"fine\"\n" + " },\n" + " {\n" + " \"matching\": \"somebad]]][[stuff\"\n" + " }\n" + " ]\n" + " }\n" + "}");
assertThat(response.statusCode(), is(422));
Errors errors = Json.read(response.content(), Errors.class);
assertThat(errors.first().getSource().getPointer(), is("/request/bodyPatterns/1"));
assertThat(errors.first().getDetail(), is("{\"matching\":\"somebad]]][[stuff\"} is not a valid match operation"));
}
use of com.github.tomakehurst.wiremock.common.Errors in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenEqualToOperandIsWrongType.
@Test
public void returnsBadEntityStatusWhenEqualToOperandIsWrongType() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"bodyPatterns\": [\n" + " {\n" + " \"equalTo\": 12\n" + " }\n" + " ]\n" + " }\n" + "}");
assertThat(response.statusCode(), is(422));
Errors errors = Json.read(response.content(), Errors.class);
assertThat(errors.first().getSource().getPointer(), is("/request/bodyPatterns/0"));
assertThat(errors.first().getTitle(), is("Error parsing JSON"));
assertThat(errors.first().getDetail(), is("equalTo operand must be a non-null string"));
}
use of com.github.tomakehurst.wiremock.common.Errors in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenInvalidRegexUsedInUrl.
@Test
public void returnsBadEntityStatusWhenInvalidRegexUsedInUrl() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{ \n" + " \"request\": { \n" + " \"urlPattern\": \"/@$&%*[[^^£$&%\" \n" + " } \n" + "}");
assertThat(response.statusCode(), is(422));
Errors errors = Json.read(response.content(), Errors.class);
assertThat(errors.first().getDetail(), equalsMultiLine("Unclosed character class near index 13\n" + "/@$&%*[[^^£$&%\n" + " ^"));
assertThat(errors.first().getSource().getPointer(), is("/request"));
}
use of com.github.tomakehurst.wiremock.common.Errors in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenInvalidRegexUsedInHeader.
@Test
public void returnsBadEntityStatusWhenInvalidRegexUsedInHeader() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"headers\": {\n" + " \"Accept\": {\n" + " \"matches\": \"%[[json[[\"\n" + " }\n" + " }\n" + " }\n" + "}");
assertThat(response.statusCode(), is(422));
Errors errors = Json.read(response.content(), Errors.class);
assertThat(errors.first().getDetail(), equalsMultiLine("Unclosed character class near index 8\n" + "%[[json[[\n" + " ^"));
assertThat(errors.first().getSource().getPointer(), is("/request/headers/Accept"));
}
Aggregations