/sigmah/src/test/java/org/sigmah/server/endpoint/gwtrpc/CountryNameOnlyBeanMappingTest.java

http://sigma-h.googlecode.com/ · Java · 49 lines · 35 code · 10 blank · 4 comment · 0 complexity · e6349305ed7d04d9a2c81ea65187bfa5 MD5 · raw file

  1. /*
  2. * All Sigmah code is released under the GNU General Public License v3
  3. * See COPYRIGHT.txt and LICENSE.txt.
  4. */
  5. package org.sigmah.server.endpoint.gwtrpc;
  6. import static org.hamcrest.CoreMatchers.equalTo;
  7. import static org.junit.Assert.assertThat;
  8. import static org.junit.Assert.assertTrue;
  9. import org.dozer.Mapper;
  10. import org.junit.Test;
  11. import org.junit.runner.RunWith;
  12. import org.sigmah.server.util.BeanMappingModule;
  13. import org.sigmah.shared.domain.AdminLevel;
  14. import org.sigmah.shared.domain.Bounds;
  15. import org.sigmah.shared.domain.Country;
  16. import org.sigmah.shared.domain.LocationType;
  17. import org.sigmah.shared.dto.CountryDTO;
  18. import org.sigmah.test.InjectionSupport;
  19. import org.sigmah.test.Modules;
  20. import com.google.inject.Inject;
  21. @RunWith(InjectionSupport.class)
  22. @Modules({BeanMappingModule.class})
  23. public class CountryNameOnlyBeanMappingTest {
  24. @Inject
  25. Mapper mapper;
  26. @Test
  27. public void countryNameOnlyMapping() {
  28. Country country = new Country();
  29. country.setId(1);
  30. country.setName("Haiti");
  31. country.getLocationTypes().add(new LocationType());
  32. country.getAdminLevels().add(new AdminLevel(1, country, "Province", false));
  33. country.setBounds(new Bounds());
  34. CountryDTO dto = mapper.map(country, CountryDTO.class, "countryNameOnly");
  35. assertThat(dto.getName(), equalTo(country.getName()));
  36. assertTrue(dto.getAdminLevels().isEmpty());
  37. assertTrue(dto.getLocationTypes().isEmpty());
  38. }
  39. }