PageRenderTime 20ms CodeModel.GetById 10ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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