String header = response.getResponseHeaders().getFirst(Validation.VALIDATION_HEADER);
Assert.assertNotNull(header);
Assert.assertTrue(Boolean.valueOf(header));
Object entity = response.getEntity(String.class);
System.out.println("entity: " + entity);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
System.out.println("exception: " + e.toString());
countViolations(e, 1, 0, 0, 0, 0, 1);
ResteasyConstraintViolation cv = e.getReturnValueViolations().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(Foo.class);
Assert.assertEquals(500, response.getStatus());
header = response.getResponseHeaders().getFirst(Validation.VALIDATION_HEADER);
Assert.assertNotNull(header);
Assert.assertTrue(Boolean.valueOf(header));
entity = response.getEntity(String.class);
System.out.println("entity: " + entity);
e = new ResteasyViolationException(String.class.cast(entity));
countViolations(e, 1, 0, 0, 0, 0, 1);
cv = e.getReturnValueViolations().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(Foo.class);
Assert.assertEquals(500, response.getStatus());
header = response.getResponseHeaders().getFirst(Validation.VALIDATION_HEADER);
Assert.assertNotNull(header);
Assert.assertTrue(Boolean.valueOf(header));
entity = response.getEntity(String.class);
System.out.println("entity: " + entity);
e = new ResteasyViolationException(String.class.cast(entity));
countViolations(e, 2, 0, 0, 0, 0, 2);
Iterator<ResteasyConstraintViolation> it = e.getReturnValueViolations().iterator();
ResteasyConstraintViolation cv1 = it.next();
ResteasyConstraintViolation cv2 = it.next();
if (cv1.toString().indexOf('1') < 0)
{
ResteasyConstraintViolation temp = cv1;