Foo foo = new Foo("p");
request.body("application/foo", foo);
request.accept(MediaType.APPLICATION_XML);
ClientResponse<?> response = request.post(Foo.class);
Assert.assertEquals(400, response.getStatus());
ViolationReport report = response.getEntity(ViolationReport.class);
System.out.println("report: " + report);
countViolations(report, 4, 2, 1, 1, 1, 0);
Iterator<ResteasyConstraintViolation> iterator = report.getFieldViolations().iterator();
ResteasyConstraintViolation cv1 = iterator.next();
ResteasyConstraintViolation cv2 = iterator.next();
if (!("a").equals(cv1.getValue()))
{
ResteasyConstraintViolation tmp = cv1;
cv1 = cv2;
cv2 = tmp;
}
Assert.assertEquals("size must be between 2 and 4", cv1.getMessage());
Assert.assertEquals("a", cv1.getValue());
Assert.assertEquals("size must be between 2 and 4", cv2.getMessage());
Assert.assertEquals("b", cv2.getValue());
ResteasyConstraintViolation cv = report.getPropertyViolations().iterator().next();
Assert.assertEquals("size must be between 3 and 5", cv.getMessage());
Assert.assertEquals("c", cv.getValue());
cv = report.getClassViolations().iterator().next();
Assert.assertEquals("Concatenation of s and u must have length > 5", cv.getMessage());
System.out.print("value: " + cv.getValue());
Assert.assertTrue(cv.getValue().startsWith("org.jboss.resteasy.test.validation.TestValidationXML$TestResourceWithAllFivePotentialViolations@"));
cv = report.getParameterViolations().iterator().next();
Assert.assertEquals("s must have length: 3 <= length <= 5", cv.getMessage());
Assert.assertEquals("Foo[p]", cv.getValue());
}
after();