use of com.github.tomakehurst.wiremock.common.Errors in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenInvalidRegexUsedInBodyPattern.
@Test
public void returnsBadEntityStatusWhenInvalidRegexUsedInBodyPattern() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"bodyPatterns\": [\n" + " {\n" + " \"equalTo\": \"fine\"\n" + " },\n" + " {\n" + " \"matches\": \"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().getTitle(), is("Error parsing JSON"));
assertThat(errors.first().getDetail(), equalsMultiLine("Unclosed character class near index 16\n" + "somebad]]][[stuff\n" + " ^"));
}
use of com.github.tomakehurst.wiremock.common.Errors in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenInvalidMatchOperator.
@Test
public void returnsBadEntityStatusWhenInvalidMatchOperator() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"bodyPatterns\": [\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/0"));
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 returnsBadEntityStatusOnEqualToJsonOperand.
@Test
public void returnsBadEntityStatusOnEqualToJsonOperand() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"bodyPatterns\": [\n" + " {\n" + " \"equalToJson\": \"(wrong)\"\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().getDetail(), allOf(containsString("Unexpected character ('(' (code 40)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')"), containsString("line: 1, column: 2")));
}
use of com.github.tomakehurst.wiremock.common.Errors in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenContainsOperandIsWrongType.
@Test
public void returnsBadEntityStatusWhenContainsOperandIsWrongType() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"bodyPatterns\": [\n" + " {\n" + " \"contains\": 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("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 returnsBadEntityStatusWhenInvalidEqualToXmlSpecified.
@Test
public void returnsBadEntityStatusWhenInvalidEqualToXmlSpecified() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"bodyPatterns\": [\n" + " {\n" + " \"equalToXml\": \"(wrong)\"\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("Content is not allowed in prolog.; line 1; column 1"));
}
Aggregations