use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method returnInvalidatedEntityIs500.
@Test
public void returnInvalidatedEntityIs500() throws Exception {
assumeThat(Locale.getDefault().getLanguage(), is("en"));
final Response response = target("/valid/fooValidated").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 postValidGroupsIs400.
@Test
public void postValidGroupsIs400() throws Exception {
final Response response = target("/valid/sub-valid-group-zoo").queryParam("address", "42 WALLABY WAY").queryParam("name", "Coda").request().post(Entity.json("{}"));
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.readEntity(String.class)).containsOnlyOnce("[\"address must not be uppercase\"]");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method invalidEmbeddedListEntities.
@Test
public void invalidEmbeddedListEntities() {
final Response response = target("/valid/validExampleEmbeddedList").request().post(Entity.json("[ {\"examples\": [ {\"id\":1 } ] }, { } ]"));
assertThat(response.getStatus()).isEqualTo(422);
assertThat(response.readEntity(String.class)).containsOnlyOnce("examples may not be empty");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method postInvalidatedEntityIs422.
@Test
public void postInvalidatedEntityIs422() throws Exception {
assumeThat(Locale.getDefault().getLanguage(), is("en"));
final Response response = target("/valid/fooValidated").request(MediaType.APPLICATION_JSON).post(Entity.entity("{}", MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(422);
assertThat(response.readEntity(String.class)).isEqualTo("{\"errors\":[\"name may not be empty\"]}");
}
use of javax.ws.rs.core.Response in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method getInvalidPathParamsIs400.
@Test
public void getInvalidPathParamsIs400() throws Exception {
final Response response = target("/valid/goods/11").request().get();
assertThat(response.getStatus()).isEqualTo(400);
String ret = "{\"errors\":[\"path param id not a well-formed email address\"]}";
assertThat(response.readEntity(String.class)).isEqualTo(ret);
}
Aggregations