mercredi 16 septembre 2015

How to test DropWizard resource that returns a collection of objects?

I'm building a service using DropWizard. I have a endpoint that is expected to return a List<Person>

My unit tests looks like:

@Test
public void testGetListOfPeople() {

assertThat(
    resources.client().target("/people/?age=10").request().get(ArrayList<Person>.class))
    .containsAll(expectedList);
}

However, request().get won't allow me to specify a parameterized collection.

I've tried getting the response directly with:

r = resources.client().target("/people/?age=10").request().get()

but then its not clear how I convert r into a List<Person>

How can I update this test to work?

Aucun commentaire:

Enregistrer un commentaire