use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method emptyParameterMessageContainsParameterName.
@Test
public void emptyParameterMessageContainsParameterName() {
final Response response = target("/valid/paramValidation").queryParam("length", "").request().get();
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.readEntity(String.class)).containsOnlyOnce("query param length may not be null");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method returnInvalidEntityIs500.
@Test
public void returnInvalidEntityIs500() throws Exception {
assumeThat(Locale.getDefault().getLanguage(), is("en"));
final Response response = target("/valid/foo").request(MediaType.APPLICATION_JSON).post(Entity.entity("{ \"name\": \"Coda\" }", MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(500);
assertThat(response.readEntity(String.class)).isEqualTo("{\"errors\":[\"server response name may not be empty\"]}");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method invalidRequestListEntities.
@Test
public void invalidRequestListEntities() {
final Response response = target("/valid/validExampleList").request().post(Entity.json("[{\"id\":-1}, {\"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 minMessageContainsParameterName.
@Test
public void minMessageContainsParameterName() {
final Response response = target("/valid/paramValidation").queryParam("length", 1).request().get();
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.readEntity(String.class)).containsOnlyOnce("query param length must be greater than or equal to 2");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method returnPartialBothValidatedRequestEntities.
@Test
public void returnPartialBothValidatedRequestEntities() {
final Response response = target("/valid/validatedPartialExampleBoth").request().post(Entity.json("{\"id\":1,\"text\":\"hello Cemo\"}"));
assertThat(response.getStatus()).isEqualTo(200);
PartialExample ex = response.readEntity(PartialExample.class);
assertThat(ex.id).isEqualTo(1);
assertThat(ex.text).isEqualTo("hello Cemo");
}
Aggregations