use of io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.Example 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);
}
use of io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.Example 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);
}
use of io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.Example in project dropwizard by dropwizard.
the class ConstraintViolationExceptionMapperTest method returnRequestCollectionEntities.
@Test
public void returnRequestCollectionEntities() {
final Response response = target("/valid/validExampleCollection").request().post(Entity.json("[{\"id\":1}, {\"id\":2}]"));
assertThat(response.getStatus()).isEqualTo(200);
final Collection<Example> example = response.readEntity(new GenericType<Collection<Example>>() {
});
Example ex1 = new Example();
Example ex2 = new Example();
ex1.id = 1;
ex2.id = 2;
assertThat(example).containsOnly(ex1, ex2);
}
Aggregations