PersonContactConverter extends
	AbstractConverter<PersonContact, PersonContactResource> { @Override public PersonContactResource convert(final PersonContact source, final PersonContactResource target) { if (source.getPerson() != null) { target.setPersonId(source.getPerson().getId()); } if (source.getContactType() != null) { target.setContactTypeId(source.getContactType().getId()); } target.setId(source.getId()); target.setValue(source.getValue()); return target; }  @Override PersonContactResource convert(final PersonContact source,
	    final PersonContactResource target); @Override PersonContactResource convert(final PersonContact source);  }
@Test public void testConvert() throws Exception { Long id = 1L; String value = "sfas"; Long personId = 2L; Person person = new Person(); person.setId(personId); Long contactTypeId = 3L; ContactType contactType = new ContactType(); contactType.setId(contactTypeId); PersonContact source = new PersonContact(); source.setPerson(person); source.setContactType(contactType); source.setId(id); source.setValue(value); PersonContactResource expected = new PersonContactResource(); expected.setPersonId(personId); expected.setContactTypeId(contactTypeId); expected.setId(id); expected.setValue(value); PersonContactResource actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithEmptyFields() throws Exception { PersonContact source = new PersonContact(); PersonContactResource expected = new PersonContactResource(); PersonContactResource actual = unit.convert(source); assertEquals(expected, actual); }