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

/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
 6package org.sigmah.server.endpoint.gwtrpc;
 7
 8import static org.hamcrest.CoreMatchers.equalTo;
 9import static org.junit.Assert.assertThat;
10import static org.junit.Assert.assertTrue;
11
12import org.dozer.Mapper;
13import org.junit.Test;
14import org.junit.runner.RunWith;
15import org.sigmah.server.util.BeanMappingModule;
16import org.sigmah.shared.domain.AdminLevel;
17import org.sigmah.shared.domain.Bounds;
18import org.sigmah.shared.domain.Country;
19import org.sigmah.shared.domain.LocationType;
20import org.sigmah.shared.dto.CountryDTO;
21import org.sigmah.test.InjectionSupport;
22import org.sigmah.test.Modules;
23
24import com.google.inject.Inject;
25
26@RunWith(InjectionSupport.class)
27@Modules({BeanMappingModule.class})
28public class CountryNameOnlyBeanMappingTest {
29
30    @Inject
31    Mapper mapper;
32
33    @Test
34    public void countryNameOnlyMapping() {
35
36        Country country = new Country();
37        country.setId(1);
38        country.setName("Haiti");
39        country.getLocationTypes().add(new LocationType());
40        country.getAdminLevels().add(new AdminLevel(1, country, "Province", false));
41        country.setBounds(new Bounds());
42
43        CountryDTO dto = mapper.map(country, CountryDTO.class, "countryNameOnly");
44
45        assertThat(dto.getName(), equalTo(country.getName()));
46        assertTrue(dto.getAdminLevels().isEmpty());
47        assertTrue(dto.getLocationTypes().isEmpty());
48    }
49}