Search in sources :

Example 1 with Example

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);
}
Also used : Response(javax.ws.rs.core.Response) Example(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.Example) PartialExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.PartialExample) ListExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.ListExample) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 2 with Example

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);
}
Also used : Response(javax.ws.rs.core.Response) Example(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.Example) PartialExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.PartialExample) ListExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.ListExample) Map(java.util.Map) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 3 with Example

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);
}
Also used : Response(javax.ws.rs.core.Response) Example(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.Example) PartialExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.PartialExample) ListExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.ListExample) Collection(java.util.Collection) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Aggregations

AbstractJerseyTest (io.dropwizard.jersey.AbstractJerseyTest)3 Example (io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.Example)3 ListExample (io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.ListExample)3 PartialExample (io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.PartialExample)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 Collection (java.util.Collection)1 Map (java.util.Map)1