/sigmah/src/test/java/org/sigmah/server/mapping/AdminEntityMappingTest.java

http://sigma-h.googlecode.com/ · Java · 61 lines · 44 code · 13 blank · 4 comment · 0 complexity · f5e0e55a0835f96fda00cf9e2455429b 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.mapping;
  6. import junit.framework.Assert;
  7. import org.dozer.Mapper;
  8. import org.junit.Test;
  9. import org.junit.runner.RunWith;
  10. import org.sigmah.server.util.BeanMappingModule;
  11. import org.sigmah.shared.domain.AdminEntity;
  12. import org.sigmah.shared.domain.AdminLevel;
  13. import org.sigmah.shared.domain.Bounds;
  14. import org.sigmah.shared.dto.AdminEntityDTO;
  15. import org.sigmah.test.InjectionSupport;
  16. import org.sigmah.test.Modules;
  17. import com.google.inject.Inject;
  18. @RunWith(InjectionSupport.class)
  19. @Modules({BeanMappingModule.class})
  20. public class AdminEntityMappingTest {
  21. @Inject
  22. Mapper mapper;
  23. @Test
  24. public void testBounds() {
  25. Bounds bounds = new Bounds();
  26. bounds.setX1(1.0);
  27. bounds.setY1(2.0);
  28. bounds.setX2(3.0);
  29. bounds.setY2(4.0);
  30. AdminLevel level = new AdminLevel();
  31. level.setId(81);
  32. level.setName("My Level");
  33. AdminEntity parent = new AdminEntity();
  34. parent.setId(93);
  35. AdminEntity entity = new AdminEntity();
  36. entity.setLevel(level);
  37. entity.setParent(parent);
  38. entity.setBounds(bounds);
  39. AdminEntityDTO dto = mapper.map(entity, AdminEntityDTO.class);
  40. Assert.assertEquals("parentId", parent.getId(), dto.getParentId().intValue());
  41. Assert.assertEquals("levelId", level.getId(), dto.getLevelId());
  42. Assert.assertNotNull("bounds", dto.getBounds());
  43. Assert.assertEquals("x1", bounds.getX1(), dto.getBounds().x1);
  44. Assert.assertEquals("y1", bounds.getY1(), dto.getBounds().y1);
  45. Assert.assertEquals("x2", bounds.getX2(), dto.getBounds().x2);
  46. Assert.assertEquals("y2", bounds.getY2(), dto.getBounds().y2);
  47. }
  48. }