use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method invalidMapRequestEntities.
@Test
public void invalidMapRequestEntities() {
final Response response = target("/valid/validExampleMap").request().post(Entity.json("{\"one\": {\"id\":-1}, \"two\": {\"id\":-2}}"));
assertThat(response.getStatus()).isEqualTo(422);
assertThat(response.readEntity(String.class)).isEqualTo("{\"errors\":[\"id must be greater than or equal to 0\"," + "\"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 getInvalidHeaderParamsIs400.
@Test
public void getInvalidHeaderParamsIs400() throws Exception {
final Response response = target("/valid/head").request().get();
assertThat(response.getStatus()).isEqualTo(400);
String ret = "{\"errors\":[\"header cheese 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 invalidEntityExceptionForPartialValidatedRequestEntities.
@Test
public void invalidEntityExceptionForPartialValidatedRequestEntities() {
final Response response = target("/valid/validatedPartialExampleBoth").request().post(Entity.json("{\"id\":1}"));
assertThat(response.getStatus()).isEqualTo(422);
assertThat(response.readEntity(String.class)).isEqualTo("{\"errors\":[\"text may not be null\"]}");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method getInvalidCustomTypeIs400.
@Test
public void getInvalidCustomTypeIs400() throws Exception {
// query parameter is too short and so will fail validation
final Response response = target("/valid/barter").queryParam("name", "hi").request().get();
assertThat(response.getStatus()).isEqualTo(400);
String ret = "{\"errors\":[\"query param name length must be between 3 and 2147483647\"]}";
assertThat(response.readEntity(String.class)).isEqualTo(ret);
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method returnsValidatedMapRequestEntities.
@Test
public void returnsValidatedMapRequestEntities() {
final Response response = target("/valid/validExampleMap").request().post(Entity.json("{\"one\": {\"id\":1}, \"two\": {\"id\":2}}"));
assertThat(response.getStatus()).isEqualTo(200);
Map<String, Example> map = response.readEntity(new GenericType<Map<String, Example>>() {
});
assertThat(map.get("one").id).isEqualTo(1);
assertThat(map.get("two").id).isEqualTo(2);
}
Aggregations