PersonResourceConverterList extends AbstractConverter<PersonResourceList, PersonList> { @Override public PersonList convert(final PersonResourceList source, final PersonList target) { target.setId(source.getId()); target.setBegDate(source.getBegDate()); target.setBirthPlaces(source.getBirthPlace()); target.setDocNums(source.getDocNum()); target.setDocSeries(source.getDocSeries()); target.setEndDate(source.getEndDate()); target.setFatherNames(source.getFatherName()); target.setFirstNames(source.getFirstName()); target.setIdentifiers(source.getIdentifier()); target.setIsHostel(source.getIsHostel()); target.setIsMilitary(source.getIsMilitary()); target.setNames(source.getName()); target.setPhotos(source.getPhoto()); target.setResident(source.getResident()); target.setSurnames(source.getSurname()); target.setNote(source.getNote()); if (source.getPersonTypeId() != null) { List<PersonType> personTypes = source.getPersonTypeId().stream() .map(id -> new PersonType(id)) .collect(Collectors.toList()); target.setPersonTypes(personTypes); } if (source.getParentId() != null) { List<Person> parents = source.getParentId().stream() .map(id -> new Person(id)) .collect(Collectors.toList()); target.setParents(parents); } if (source.getMarriedTypeId() != null) { List<MarriedType> marriedTypes = source.getMarriedTypeId().stream() .map(id -> new MarriedType(id)) .collect(Collectors.toList()); target.setMarriedTypes(marriedTypes); } if (source.getCitizenCountryId() != null) { List<AdminUnit> adminUnits = source.getCitizenCountryId().stream() .map(id -> new AdminUnit(id)) .collect(Collectors.toList()); target.setCitizenCountries(adminUnits); } if (source.getGenderTypeId() != null) { List<GenderType> genderTypes = source.getGenderTypeId().stream() .map(id -> new GenderType(id)) .collect(Collectors.toList()); target.setGenderTypes(genderTypes); } return target; }  @Override PersonList convert(final PersonResourceList source, final PersonList target); @Override PersonList convert(final PersonResourceList source);  }
@Test public void testConvert() throws Exception { PersonResourceList source = new PersonResourceList(); PersonList expected = new PersonList(); PersonList actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWith() throws Exception { Long parentId = 1L; Long personTypeId = 2L; Long marriedTypeId = 3L; Long genderTypeId = 4L; Long citizenCountryId = 5L; PersonResourceList source = new PersonResourceList(); source.setPersonTypeId(Arrays.asList(personTypeId)); source.setParentId(Arrays.asList(parentId)); source.setMarriedTypeId(Arrays.asList(marriedTypeId)); source.setCitizenCountryId(Arrays.asList(citizenCountryId)); source.setGenderTypeId(Arrays.asList(genderTypeId)); PersonList expected = new PersonList(); expected.setPersonTypes(Arrays.asList(new PersonType(personTypeId))); expected.setParents(Arrays.asList(new Person(parentId))); expected.setMarriedTypes(Arrays.asList(new MarriedType(marriedTypeId))); expected.setCitizenCountries(Arrays.asList(new AdminUnit(citizenCountryId))); expected.setGenderTypes(Arrays.asList(new GenderType(genderTypeId))); PersonList actual = unit.convert(source); assertEquals(expected, actual); }