ClientRequest request = new ClientRequest(generateURL("/none"));
request.body(MediaType.TEXT_PLAIN_TYPE, "abc");
ClientResponse<?> response = request.post(String.class);
Assert.assertEquals(400, response.getStatus());
String entity = response.getEntity(String.class);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
System.out.println(e);
countViolations(e, 2, 0, 2, 0, 0, 0);
}
{
// No method validation. Two property violations.
ClientRequest request = new ClientRequest(generateURL("/getterOnNonGetter"));
request.body(MediaType.TEXT_PLAIN_TYPE, "abc");
ClientResponse<?> response = request.post(Serializable.class);
Assert.assertEquals(400, response.getStatus());
String entity = response.getEntity(String.class);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
System.out.println(e);
countViolations(e, 2, 0, 2, 0, 0, 0);
}
{
// No method validation. Two property violations
ClientRequest request = new ClientRequest(generateURL("/nonGetterOnGetter"));
ClientResponse<?> response = request.post(Serializable.class);
Assert.assertEquals(400, response.getStatus());
String entity = response.getEntity(String.class);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
System.out.println(e);
countViolations(e, 2, 0, 2, 0, 0, 0);
}
{
// Failure.
ClientRequest request = new ClientRequest(generateURL("/implicitOnNonGetter"));
request.body(MediaType.TEXT_PLAIN_TYPE, "abc");
ClientResponse<?> response = request.post(Serializable.class);
Assert.assertEquals(400, response.getStatus());
String entity = response.getEntity(String.class);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
System.out.println(e);
countViolations(e, 3, 0, 2, 0, 1, 0);
}
{
// Failure.
ClientRequest request = new ClientRequest(generateURL("/implicitOnGetter"));
ClientResponse<?> response = request.post(Serializable.class);
Assert.assertEquals(400, response.getStatus());
String entity = response.getEntity(String.class);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
countViolations(e, 2, 0, 2, 0, 0, 0);
}
{
// Failure.
ClientRequest request = new ClientRequest(generateURL("/allOnNonGetter"));
request.body(MediaType.TEXT_PLAIN_TYPE, "abc");
ClientResponse<?> response = request.post(Serializable.class);
Assert.assertEquals(400, response.getStatus());
String entity = response.getEntity(String.class);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
countViolations(e, 3, 0, 2, 0, 1, 0);
}
{
// Failure.
ClientRequest request = new ClientRequest(generateURL("/allOnGetter"));
ClientResponse<?> response = request.post(Serializable.class);
Assert.assertEquals(400, response.getStatus());
String entity = response.getEntity(String.class);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
countViolations(e, 2, 0, 2, 0, 0, 0);
}
{
// Failure.
ClientRequest request = new ClientRequest(generateURL("/override"));
request.body(MediaType.TEXT_PLAIN_TYPE, "abc");
ClientResponse<?> response = request.post(Serializable.class);
Assert.assertEquals(400, response.getStatus());
String entity = response.getEntity(String.class);
ResteasyViolationException e = new ResteasyViolationException(String.class.cast(entity));
countViolations(e, 3, 0, 2, 0, 1, 0);
}
after();
}