@Test
public void generateErrorMessage_shouldCreateATextErrorDocument() throws Exception {
JsonSchemaProvider provider = new JsonSchemaProvider(mock(SchemaLookup.class));
ErrorMessage errorA = new ErrorMessage("foo.bar", "errorAMessage");
ErrorMessage errorB = new ErrorMessage("foo.baz", "errorBMessage");
List<ErrorMessage> validationErrors = Arrays.asList(errorA, errorB);
Response response = provider.generateErrorMessage(validationErrors);
assertEquals(400, response.getStatus());
assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMetadata().getFirst("Content-Type"));
String entity = (String) response.getEntity();
assertTrue(entity.contains(errorA.getLocation() + ": "));
assertTrue(entity.contains(errorA.getMessage()));
assertTrue(entity.contains(errorB.getLocation() + ": "));
assertTrue(entity.contains(errorB.getMessage()));
}