response = request.post(String.class);
Assert.assertEquals(400, response.getStatus());
Object entity = response.getEntity();
ViolationReport r = new ViolationReport(String.class.cast(entity));
countViolations(r, 0, 0, 0, 1, 0);
ResteasyConstraintViolation cv = r.getParameterViolations().iterator().next();
Assert.assertTrue(cv.getMessage().equals("s must have length: 1 <= length <= 3"));
Assert.assertEquals("Foo[abcdef]", cv.getValue());
// Invalid imposed constraint
request = new ClientRequest(generateURL("/imposed"));
request.body("application/foo", new Foo("abcdef"));
response = request.post(String.class);
Assert.assertEquals(400, response.getStatus());
entity = response.getEntity();
r = new ViolationReport(String.class.cast(entity));
countViolations(r, 0, 0, 0, 1, 0);
cv = r.getParameterViolations().iterator().next();
Assert.assertTrue(cv.getMessage().equals("s must have length: 3 <= length <= 5"));
Assert.assertEquals("Foo[abcdef]", cv.getValue());
// Invalid native and imposed constraints
request = new ClientRequest(generateURL("/nativeAndImposed"));
request.body("application/foo", new Foo("abcdef"));
response = request.post(String.class);
Assert.assertEquals(400, response.getStatus());
entity = response.getEntity();
r = new ViolationReport(String.class.cast(entity));
countViolations(r, 0, 0, 0, 2, 0);
Iterator<ResteasyConstraintViolation> it = r.getParameterViolations().iterator();
ResteasyConstraintViolation cv1 = it.next();
ResteasyConstraintViolation cv2 = it.next();
if (cv1.toString().indexOf('1') < 0)
{
ResteasyConstraintViolation temp = cv1;
cv1 = cv2;
cv2 = temp;
}
Assert.assertTrue(cv1.getMessage().equals("s must have length: 1 <= length <= 3"));
Assert.assertEquals("Foo[abcdef]", cv1.getValue());