use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method testInvalidFieldQueryParam.
@Test
public void testInvalidFieldQueryParam() {
final Response response = target("/valid/bar").queryParam("sort", "foo").request().get();
assertThat(response.getStatus()).isEqualTo(422);
assertThat(response.readEntity(String.class)).containsOnlyOnce("sortParam must match \\\"^(asc|desc)$\\\"");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method getInvalidNested2ReturnIs500.
@Test
public void getInvalidNested2ReturnIs500() throws Exception {
final Response response = target("/valid/nested2").request().get();
assertThat(response.getStatus()).isEqualTo(500);
String ret = "{\"errors\":[\"server response example must have a false thing\"]}";
assertThat(response.readEntity(String.class)).isEqualTo(ret);
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method throwsAConstraintViolationExceptionForEmptyRequestEntities.
@Test
public void throwsAConstraintViolationExceptionForEmptyRequestEntities() {
final Response response = target("/valid/validExample").request().post(Entity.json(null));
assertThat(response.getStatus()).isEqualTo(422);
assertThat(response.readEntity(String.class)).isEqualTo("{\"errors\":[\"The request body may not be null\"]}");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method notPresentEnumParameter.
@Test
public void notPresentEnumParameter() {
final Response response = target("/valid/enumParam").request().get();
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.readEntity(String.class)).containsOnlyOnce("query param choice may not be null");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method getInvalidSubBeanParamsIs400.
@Test
public void getInvalidSubBeanParamsIs400() throws Exception {
final Response response = target("/valid/sub-zoo").queryParam("address", "42 Wallaby Way").request().get();
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.readEntity(String.class)).containsOnlyOnce("query param name may not be empty").containsOnlyOnce("name must be Coda");
}
Aggregations