use of org.glassfish.jersey.examples.entityfiltering.selectable.domain.PhoneNumber in project jersey by jersey.
the class PersonResource method getPerson.
@GET
@Path("{id}")
public Person getPerson() {
final Person person = new Person();
person.setGivenName("Andrew");
person.setFamilyName("Dowd");
person.setHonorificPrefix("Mr.");
person.setHonorificSuffix("PhD");
person.setRegion("1st Level Region");
final ArrayList<Address> addresses = new ArrayList<>();
person.setAddresses(addresses);
final Address address = new Address();
addresses.add(address);
address.setRegion("2nd Level Region");
address.setStreetAddress("1234 fake st.");
address.setPhoneNumber(new PhoneNumber());
address.getPhoneNumber().setNumber("867-5309");
address.getPhoneNumber().setAreaCode("540");
person.setPhoneNumbers(new HashMap<String, PhoneNumber>());
final PhoneNumber number = new PhoneNumber();
number.setAreaCode("804");
number.setNumber("867-5309");
person.getPhoneNumbers().put("HOME", number);
return person;
}
use of org.glassfish.jersey.examples.entityfiltering.selectable.domain.PhoneNumber in project jersey by jersey.
the class PersonResourceTest method testNoFilter.
@Test
public void testNoFilter() throws Exception {
final Person entity = target("people").path("1234").request().get(Person.class);
// Not null values.
assertThat(entity.getFamilyName(), notNullValue());
assertThat(entity.getGivenName(), notNullValue());
assertThat(entity.getHonorificPrefix(), notNullValue());
assertThat(entity.getHonorificSuffix(), notNullValue());
assertThat(entity.getRegion(), notNullValue());
final List<Address> addresses = entity.getAddresses();
assertThat(addresses, notNullValue());
final Address address = addresses.get(0);
assertThat(address, notNullValue());
assertThat(address.getRegion(), notNullValue());
assertThat(address.getStreetAddress(), notNullValue());
PhoneNumber phoneNumber = address.getPhoneNumber();
assertThat(phoneNumber, notNullValue());
assertThat(phoneNumber.getAreaCode(), notNullValue());
assertThat(phoneNumber.getNumber(), notNullValue());
final Map<String, PhoneNumber> phoneNumbers = entity.getPhoneNumbers();
assertThat(phoneNumbers, notNullValue());
// TODO: enable for MOXy as well when JERSEY-2751 gets fixed.
if (JacksonFeature.class.isAssignableFrom(filteringProvider)) {
phoneNumber = phoneNumbers.get("HOME");
assertThat(phoneNumber, notNullValue());
assertThat(phoneNumber.getAreaCode(), notNullValue());
assertThat(phoneNumber.getNumber(), notNullValue());
}
}
Aggregations