Search in sources :

Example 6 with Person

use of org.glassfish.jersey.examples.entityfiltering.selectable.domain.Person in project jersey by jersey.

the class PersonResourceTest method testFiltersSameName.

/**
     * Test that 1st and 2nd level filters with the same name act as expected.
     */
@Test
public void testFiltersSameName() throws Exception {
    final Person firstLevel = target("people").path("1234").queryParam("select", "familyName,region").request().get(Person.class);
    final Person secondLevel = target("people").path("1234").queryParam("select", "familyName,addresses.region").request().get(Person.class);
    // Not null values.
    assertThat(firstLevel.getRegion(), notNullValue());
    assertThat(secondLevel.getAddresses().get(0).getRegion(), notNullValue());
    // Null values.
    //confirms 2nd level region on addresses is null
    assertThat(firstLevel.getAddresses(), nullValue());
    assertThat(secondLevel.getRegion(), nullValue());
}
Also used : Person(org.glassfish.jersey.examples.entityfiltering.selectable.domain.Person) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Aggregations

Person (org.glassfish.jersey.examples.entityfiltering.selectable.domain.Person)6 JerseyTest (org.glassfish.jersey.test.JerseyTest)5 Test (org.junit.Test)5 Address (org.glassfish.jersey.examples.entityfiltering.selectable.domain.Address)2 PhoneNumber (org.glassfish.jersey.examples.entityfiltering.selectable.domain.PhoneNumber)2 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1