use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method returnPartialValidatedRequestEntities.
@Test
public void returnPartialValidatedRequestEntities() {
final Response response = target("/valid/validatedPartialExample").request().post(Entity.json("{\"id\":1}"));
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.readEntity(PartialExample.class).id).isEqualTo(1);
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method invalidRequestSingleCollectionEntities.
@Test
public void invalidRequestSingleCollectionEntities() {
final Response response = target("/valid/validExampleCollection").request().post(Entity.json("[{\"id\":1}, {\"id\":-2}]"));
assertThat(response.getStatus()).isEqualTo(422);
assertThat(response.readEntity(String.class)).containsOnlyOnce("id must be greater than or equal to 0");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method getInvalidatedBeanParamsIs400.
@Test
public void getInvalidatedBeanParamsIs400() throws Exception {
// bean parameter is too short and so will fail validation
final Response response = target("/valid/zoo2").request().get();
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.readEntity(String.class)).containsOnlyOnce("\"name must be Coda\"").containsOnlyOnce("\"query param name may not be empty\"");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method getInvalidMatrixParamIs400.
@Test
public void getInvalidMatrixParamIs400() throws Exception {
final Response response = target("/valid/matrix").matrixParam("bob", "").request().get();
assertThat(response.getStatus()).isEqualTo(400);
String ret = "{\"errors\":[\"matrix param bob may not be empty\"]}";
assertThat(response.readEntity(String.class)).isEqualTo(ret);
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method returnRequestArrayEntities.
@Test
public void returnRequestArrayEntities() {
final Response response = target("/valid/validExampleArray").request().post(Entity.json("[{\"id\":1}, {\"id\":2}]"));
final Example ex1 = new Example();
final Example ex2 = new Example();
ex1.id = 1;
ex2.id = 2;
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.readEntity(Example[].class)).containsExactly(ex1, ex2);
}
Aggregations