Clover Coverage Report - Kuali Student 1.3.0-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Apr 28 2011 05:03:32 EDT
55   103   2   27.5
0   78   0.04   2
2     1  
1    
 
  TestDataMapper       Line # 20 55 0% 2 57 0% 0.0
 
No Tests
 
1    package org.kuali.student.core.assembly.data;
2   
3    import static org.junit.Assert.assertEquals;
4   
5    import java.text.DateFormat;
6    import java.text.SimpleDateFormat;
7    import java.util.ArrayList;
8    import java.util.HashMap;
9    import java.util.List;
10    import java.util.Map;
11   
12    import org.junit.Before;
13    import org.junit.Test;
14    import org.kuali.student.common.assembly.data.Data;
15    import org.kuali.student.common.assembly.data.Metadata;
16    import org.kuali.student.common.assembly.transform.DataBeanMapper;
17    import org.kuali.student.common.assembly.transform.DefaultDataBeanMapper;
18   
19   
 
20    public class TestDataMapper {
21   
22    MockPerson person;
23   
 
24  0 toggle @Before
25    public void setup() throws Exception{
26  0 person = new MockPerson();
27  0 person.setFirstName("first");
28  0 person.setLastName("last");
29  0 person.setEmail("first@test.com");
30  0 person.setType("STUDENT");
31  0 person.setState("CREATE");
32  0 person.setId("P1");
33  0 person.setGpa(3.5);
34  0 DateFormat df = new SimpleDateFormat("yy-MM-DD");
35  0 person.setDob(df.parse("1978-01-01"));
36   
37   
38  0 MockAddress address = new MockAddress();
39  0 address.setState("ACTIVE");
40  0 address.setType("MAILING");
41  0 address.setId("A1");
42  0 address.setCity("TLH");
43  0 address.setStateCode("FL");
44  0 address.setCountry("US");
45  0 address.setLine1("");
46  0 address.setLine2("line2value");
47  0 address.setPostalCode("32306");
48   
49    //Add a dynamic attribute
50  0 Map<String,String> attributes = new HashMap<String,String>();
51  0 attributes.put("POBox", "1145");
52  0 attributes.put("building", "Residential");
53  0 address.setAttributes(attributes);
54   
55  0 List<MockAddress> addressL = new ArrayList<MockAddress>();
56  0 addressL.add(address);
57   
58  0 person.setAddress(addressL);
59   
60   
61    }
62   
 
63  0 toggle @Test
64    public void testConverDTOtoData() throws Exception {
65  0 DataBeanMapper dataMapper = new DefaultDataBeanMapper();
66   
67  0 Data data = dataMapper.convertFromBean(person);
68  0 Metadata metadata = new Metadata();
69  0 MockPerson convertedPerson = (MockPerson)dataMapper.convertFromData(data, MockPerson.class,metadata);
70   
71  0 assertEquals(person.getDob(), convertedPerson.getDob());
72  0 assertEquals(person.getEmail(), convertedPerson.getEmail());
73  0 assertEquals(person.getFirstName(), convertedPerson.getFirstName());
74  0 assertEquals(person.getGpa(), convertedPerson.getGpa());
75  0 assertEquals(person.getId(), convertedPerson.getId());
76  0 assertEquals(person.getLastName(), convertedPerson.getLastName());
77  0 assertEquals(person.getState(), convertedPerson.getState());
78  0 assertEquals(person.getType(), convertedPerson.getType());
79   
80  0 assertEquals(convertedPerson.getAddress().size(),1);
81   
82  0 MockAddress address = person.getAddress().get(0);
83  0 MockAddress convertedAddress = convertedPerson.getAddress().get(0);
84   
85  0 assertEquals(address.getCity(), convertedAddress.getCity());
86  0 assertEquals(address.getCountry(), convertedAddress.getCountry());
87  0 assertEquals(address.getId(), convertedAddress.getId());
88  0 assertEquals(address.getLine1(), convertedAddress.getLine1());
89  0 assertEquals(address.getLine2(), convertedAddress.getLine2());
90  0 assertEquals(address.getPostalCode(), convertedAddress.getPostalCode());
91  0 assertEquals(address.getState(), convertedAddress.getState());
92  0 assertEquals(address.getStateCode(), convertedAddress.getStateCode());
93  0 assertEquals(address.getType(), convertedAddress.getType());
94   
95  0 Map<String,String> attributes = convertedAddress.getAttributes();
96  0 assertEquals(attributes.size(),2);
97  0 assertEquals(attributes.get("POBox"),"1145");
98  0 assertEquals(attributes.get("building"),"Residential");
99    }
100   
101   
102   
103    }