Package com.inspiresoftware.lib.dto.geda.benchmark.domain

Examples of com.inspiresoftware.lib.dto.geda.benchmark.domain.Person


*/
public class ManualListMapper implements Mapper {

    public Object fromEntity(final Object entity) {

        final Person person = (Person) entity;
        final PersonWithHistoryDTO dto = new PersonWithHistoryDTO();
        if (person.getPreviousAddresses() != null) {
            dto.setPreviousAddresses(new ArrayList<AddressDTO>());
            for (final Address address : person.getPreviousAddresses()) {
                dto.getPreviousAddresses().add(fromAddress(address));
            }
        }
        if (person.getName() != null) {
            dto.setFirstName(person.getName().getFirstname());
            dto.setLastName(person.getName().getSurname());
        }
        if (person.getCurrentAddress() != null) {
            final Address address = person.getCurrentAddress();
            final AddressDTO addressDTO = fromAddress(address);
            dto.setCurrentAddress(addressDTO);
        }
        dto.setId(person.getId());
        return dto;
    }
View Full Code Here


        return addressDTO;
    }

    public Object fromDto(final Object dto) {

        final Person person = new Person();
        final PersonWithHistoryDTO personDTO = (PersonWithHistoryDTO) dto;

        person.setName(new Name(personDTO.getFirstName(), personDTO.getLastName()));

        if (personDTO.getCurrentAddress() != null) {
            final AddressDTO addressDTO = personDTO.getCurrentAddress();
            final Address address = fromAddressDTO(addressDTO);

            person.setCurrentAddress(address);
        }
        person.setPreviousAddresses(new ArrayList<Address>());
        for (final AddressDTO addressDTO : personDTO.getPreviousAddresses()) {
            person.getPreviousAddresses().add(fromAddressDTO(addressDTO));
        }
        person.setId(personDTO.getId());
        return person;
    }
View Full Code Here

*/
public class ManualBasicMapper implements Mapper {

    public Object fromEntity(final Object entity) {

        final Person person = (Person) entity;
        final PersonDTO dto = new PersonDTO();

        dto.setId(person.getId());
        if (person.getName() != null) {
            dto.setFirstName(person.getName().getFirstname());
            dto.setLastName(person.getName().getSurname());
        }
        if (person.getCurrentAddress() != null) {
            final Address address = person.getCurrentAddress();
            final AddressDTO addressDTO = fromAddress(address);
            dto.setCurrentAddress(addressDTO);
        }
        return dto;
    }
View Full Code Here

        return addressDTO;
    }

    public Object fromDto(final Object dto) {

        final Person person = new Person();
        final PersonDTO personDTO = (PersonDTO) dto;

        person.setId(personDTO.getId());
        person.setName(new Name(personDTO.getFirstName(), personDTO.getLastName()));

        if (personDTO.getCurrentAddress() != null) {
            final AddressDTO addressDTO = personDTO.getCurrentAddress();
            final Address address = fromAddressDTO(addressDTO);

            person.setCurrentAddress(address);
        }
        return person;
    }
View Full Code Here


    @Test
    public void testMapper() throws Exception {

        final Person entity = getEntity();
        final PersonDTO dto = getDto();

        final Mapper mapper = new DozerBasicMapper();

        assertEquals(entity, mapper.fromDto(dto));
View Full Code Here


    @Test
    public void testMapper() throws Exception {

        final Person entity = getEntityWithHistory();
        final PersonDTO dto = getDtoWithHistory();

        final Mapper mapper = new DozerListMapper();

        final Person fromDto = (Person) mapper.fromDto(dto);
        assertEquals(entity, fromDto);
        assertNotNull(fromDto.getPreviousAddresses());
        assertEquals(2, fromDto.getPreviousAddresses().size());
        assertEquals(entity.getPreviousAddresses().get(0), fromDto.getPreviousAddresses().get(0));

        final PersonWithHistoryDTO fromEntity = (PersonWithHistoryDTO) mapper.fromEntity(entity);
        assertEquals(dto, fromEntity);
        assertNotNull(fromEntity.getPreviousAddresses());
        assertEquals(2, fromEntity.getPreviousAddresses().size());
View Full Code Here

    public void testBasicMapping() throws Exception {


        final BeanFactory bf = new GeDABeanFactory();

        final Person entity = DataProvider.providePersonEntity(false);

        final PersonDTO dto = new PersonDTO();

        final Assembler asm = DTOAssembler.newAssembler(PersonDTO.class, Person.class, this.getClass().getClassLoader());
View Full Code Here

    public void testCollectionsMapping() throws Exception {


        final BeanFactory bf = new GeDABeanFactory();

        final Person entity = DataProvider.providePersonEntity(true);

        final PersonWithHistoryDTO dto = new PersonWithHistoryDTO();

        final Assembler asm = DTOAssembler.newAssembler(PersonWithHistoryDTO.class, Person.class, this.getClass().getClassLoader());
View Full Code Here

    public void testMapsMapping() throws Exception {


        final BeanFactory bf = new GeDABeanFactory();

        final Person entity = DataProvider.providePersonEntity(true);

        final PersonWithHistoryByCityDTO dto = new PersonWithHistoryByCityDTO();

        final Assembler asm = DTOAssembler.newAssembler(PersonWithHistoryByCityDTO.class, Person.class, this.getClass().getClassLoader());
View Full Code Here

    protected void setUp() throws Exception {

        final Name name = new Name("Sherlock", "Holmes");
        final Country country = new Country("United Kingdom");
        final Address address = new Address("221B Baker Street", null, "London", country, "NW1 6XE");
        final Person entity = new Person(1234567890123L, name, address);

        personLoaded = entity;

        final PersonDTO dto = new PersonDTO();
        dto.setFirstName("Sherlock");
View Full Code Here

TOP

Related Classes of com.inspiresoftware.lib.dto.geda.benchmark.domain.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.