@Test public void create_an_exact_copy_of_a_domain_contact() { Contact contact = createFullContact(); PresentationContact mappedContact = contactMapper.map(contact); assertThat(contact.getMd5(), is(mappedContact.getMd5())); assertThat(contact.getCell(), is(mappedContact.getCell())); assertThat(contact.getEmail(), is(mappedContact.getEmail())); assertThat(contact.getGender(), is(mappedContact.getGender())); assertThat(contact.getName().getFirst(), is(mappedContact.getFirstName())); assertThat(contact.getName().getLast(), is(mappedContact.getLastName())); assertThat(contact.getName().getTitle(), is(mappedContact.getTitle())); assertThat(contact.getPhone(), is(mappedContact.getPhone())); assertThat(contact.getPassword(), is(mappedContact.getPassword())); assertThat(contact.getUsername(), is(mappedContact.getUsername())); assertThat(contact.getVersion(), is(mappedContact.getVersion())); assertThat(contact.getLocation().getCity(), is(mappedContact.getLocation().getCity())); assertThat(contact.getLocation().getState(), is(mappedContact.getLocation().getState())); assertThat(contact.getLocation().getStreet(), is(mappedContact.getLocation().getStreet())); assertThat(contact.getLocation().getZip(), is(mappedContact.getLocation().getZip())); assertThat(contact.getPicture().getThumbnail(), is(mappedContact.getPicture().getThumbnail())); assertThat(contact.getPicture().getLarge(), is(mappedContact.getPicture().getLarge())); assertThat(contact.getPicture().getMedium(), is(mappedContact.getPicture().getMedium())); }
@Override public PresentationContact map(Contact model) { if (model == null) { return null; } PresentationContact presentationContact = new PresentationContact(); presentationContact.setMd5(model.getMd5()); presentationContact.setCell(model.getCell()); presentationContact.setEmail(model.getEmail()); presentationContact.setGender(model.getGender()); Name name = model.getName(); if (name != null) { presentationContact.setFirstName(name.getFirst()); presentationContact.setLastName(name.getLast()); presentationContact.setTitle(name.getTitle()); } presentationContact.setPhone(model.getPhone()); presentationContact.setPassword(model.getPassword()); presentationContact.setUsername(model.getUsername()); presentationContact.setVersion(model.getVersion()); presentationContact.setLocation(PRESENTATION_LOCATION_MAPPER.map(model.getLocation())); presentationContact.setPicture(PRESENTATION_PICTURE_MAPPER.map(model.getPicture())); return presentationContact; } }
@Test public void create_an_exact_copy_of_a_bdd_contact() { BddContact bddContact = createFullBddContact(); Contact mappedContact = contactMapper.map(bddContact); assertThat(bddContact.getMd5(), is(mappedContact.getMd5())); assertThat(bddContact.getCell(), is(mappedContact.getCell())); assertThat(bddContact.getEmail(), is(mappedContact.getEmail())); assertThat(bddContact.getGender(), is(mappedContact.getGender())); assertThat(bddContact.getName().getFirst(), is(mappedContact.getName().getFirst())); assertThat(bddContact.getName().getLast(), is(mappedContact.getName().getLast())); assertThat(bddContact.getName().getTitle(), is(mappedContact.getName().getTitle())); assertThat(bddContact.getPhone(), is(mappedContact.getPhone())); assertThat(bddContact.getPassword(), is(mappedContact.getPassword())); assertThat(bddContact.getUsername(), is(mappedContact.getUsername())); assertThat(bddContact.getVersion(), is(mappedContact.getVersion())); assertThat(bddContact.getLocation().getCity(), is(mappedContact.getLocation().getCity())); assertThat(bddContact.getLocation().getState(), is(mappedContact.getLocation().getState())); assertThat(bddContact.getLocation().getStreet(), is(mappedContact.getLocation().getStreet())); assertThat(bddContact.getLocation().getZip(), is(mappedContact.getLocation().getZip())); assertThat(bddContact.getPicture().getThumbnail(), is(mappedContact.getPicture().getThumbnail())); assertThat(bddContact.getPicture().getLarge(), is(mappedContact.getPicture().getLarge())); assertThat(bddContact.getPicture().getMedium(), is(mappedContact.getPicture().getMedium())); }
@Test public void create_an_exact_copy_of_a_api_contact() { ApiContact apiContact = createFullContact(); Contact mappedContact = contactMapper.map(apiContact); assertThat(apiContact.getMd5(), is(mappedContact.getMd5())); assertThat(apiContact.getCell(), is(mappedContact.getCell())); assertThat(apiContact.getEmail(), is(mappedContact.getEmail())); assertThat(apiContact.getGender(), is(mappedContact.getGender())); assertThat(apiContact.getName().getFirst(), is(mappedContact.getName().getFirst())); assertThat(apiContact.getName().getLast(), is(mappedContact.getName().getLast())); assertThat(apiContact.getName().getTitle(), is(mappedContact.getName().getTitle())); assertThat(apiContact.getPhone(), is(mappedContact.getPhone())); assertThat(apiContact.getPassword(), is(mappedContact.getPassword())); assertThat(apiContact.getUsername(), is(mappedContact.getUsername())); assertThat(apiContact.getVersion(), is(mappedContact.getVersion())); assertThat(apiContact.getLocation().getCity(), is(mappedContact.getLocation().getCity())); assertThat(apiContact.getLocation().getState(), is(mappedContact.getLocation().getState())); assertThat(apiContact.getLocation().getStreet(), is(mappedContact.getLocation().getStreet())); assertThat(apiContact.getLocation().getZip(), is(mappedContact.getLocation().getZip())); assertThat(apiContact.getPicture().getThumbnail(), is(mappedContact.getPicture().getThumbnail())); assertThat(apiContact.getPicture().getLarge(), is(mappedContact.getPicture().getLarge())); assertThat(apiContact.getPicture().getMedium(), is(mappedContact.getPicture().getMedium())); }
@Test public void create_an_exact_copy_of_a_domain_contact() { Contact contact = createFullContact(); BddContact mappedContact = contactMapper.inverseMap(contact); assertThat(contact.getMd5(), is(mappedContact.getMd5())); assertThat(contact.getCell(), is(mappedContact.getCell())); assertThat(contact.getEmail(), is(mappedContact.getEmail())); assertThat(contact.getGender(), is(mappedContact.getGender())); assertThat(contact.getName().getFirst(), is(mappedContact.getName().getFirst())); assertThat(contact.getName().getLast(), is(mappedContact.getName().getLast())); assertThat(contact.getName().getTitle(), is(mappedContact.getName().getTitle())); assertThat(contact.getPhone(), is(mappedContact.getPhone())); assertThat(contact.getPassword(), is(mappedContact.getPassword())); assertThat(contact.getUsername(), is(mappedContact.getUsername())); assertThat(contact.getVersion(), is(mappedContact.getVersion())); assertThat(contact.getLocation().getCity(), is(mappedContact.getLocation().getCity())); assertThat(contact.getLocation().getState(), is(mappedContact.getLocation().getState())); assertThat(contact.getLocation().getStreet(), is(mappedContact.getLocation().getStreet())); assertThat(contact.getLocation().getZip(), is(mappedContact.getLocation().getZip())); assertThat(contact.getPicture().getThumbnail(), is(mappedContact.getPicture().getThumbnail())); assertThat(contact.getPicture().getLarge(), is(mappedContact.getPicture().getLarge())); assertThat(contact.getPicture().getMedium(), is(mappedContact.getPicture().getMedium())); }
@Override public BddContact inverseMap(Contact model) { if (model == null) { return null; } BddContact contact = new BddContact(); contact.setMd5(model.getMd5()); contact.setCell(model.getCell()); contact.setEmail(model.getEmail()); contact.setGender(model.getGender()); contact.setName(NAME_MAPPER.inverseMap(model.getName())); contact.setPhone(model.getPhone()); contact.setPassword(model.getPassword()); contact.setUsername(model.getUsername()); contact.setVersion(model.getVersion()); contact.setLocation(LOCATION_MAPPER.inverseMap(model.getLocation())); contact.setPicture(PICTURE_MAPPER.inverseMap(model.getPicture())); return contact; }