Clover Coverage Report - Kuali Student 1.2-M5-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Aug 29 2011 05:04:27 EDT
56   111   9   6.22
0   97   0.16   9
9     1  
1    
 
  BasicContextImplTest       Line # 15 56 0% 9 0 100% 1.0
 
  (4)
 
1    package org.kuali.student.lum.statement.config.context;
2   
3    import java.util.ArrayList;
4    import java.util.List;
5    import java.util.Map;
6   
7    import org.junit.Assert;
8    import org.junit.Before;
9    import org.junit.Test;
10    import org.kuali.student.common.exceptions.OperationFailedException;
11    import org.kuali.student.core.statement.dto.ReqCompFieldInfo;
12    import org.kuali.student.core.statement.dto.ReqComponentInfo;
13    import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes;
14   
 
15    public class BasicContextImplTest {
16    private BasicContextImpl basicContext = new BasicContextImpl();
17    private ReqComponentInfo reqComponent1;
18    private ReqComponentInfo reqComponent2;
19    private ReqComponentInfo reqComponent3;
20    private ReqComponentInfo reqComponent4;
21   
 
22  4 toggle private void setupReqComponent1() {
23  4 reqComponent1 = new ReqComponentInfo();
24  4 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>();
25  4 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo();
26  4 reqCompField1.setType(ReqComponentFieldTypes.OPERATOR_KEY.getId());
27  4 reqCompField1.setValue(">");
28  4 reqCompFieldList.add(reqCompField1);
29  4 ReqCompFieldInfo reqCompField2 = new ReqCompFieldInfo();
30  4 reqCompField2.setType(ReqComponentFieldTypes.INTEGER_VALUE1_KEY.getId());
31  4 reqCompField2.setValue("1");
32  4 reqCompFieldList.add(reqCompField2);
33  4 reqComponent1.setReqCompFields(reqCompFieldList);
34    }
35   
 
36  4 toggle private void setupReqComponent2() {
37  4 reqComponent2 = new ReqComponentInfo();
38  4 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>();
39  4 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo();
40  4 reqCompField1.setType(ReqComponentFieldTypes.INTEGER_VALUE1_KEY.getId());
41  4 reqCompField1.setValue("1");
42  4 reqCompFieldList.add(reqCompField1);
43  4 reqComponent2.setReqCompFields(reqCompFieldList);
44    }
45   
 
46  4 toggle private void setupReqComponent3() {
47  4 reqComponent3 = new ReqComponentInfo();
48  4 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>();
49  4 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo();
50  4 reqCompField1.setType(ReqComponentFieldTypes.INTEGER_VALUE1_KEY.getId());
51  4 reqCompField1.setValue(null);
52  4 reqCompFieldList.add(reqCompField1);
53  4 reqComponent3.setReqCompFields(reqCompFieldList);
54    }
55   
 
56  4 toggle private void setupReqComponent4() {
57  4 reqComponent4 = new ReqComponentInfo();
58  4 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>();
59  4 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo();
60  4 reqCompField1.setType(ReqComponentFieldTypes.OPERATOR_KEY.getId());
61  4 reqCompField1.setValue(null);
62  4 reqCompFieldList.add(reqCompField1);
63  4 ReqCompFieldInfo reqCompField2 = new ReqCompFieldInfo();
64  4 reqCompField2.setType(ReqComponentFieldTypes.INTEGER_VALUE1_KEY.getId());
65  4 reqCompField2.setValue(null);
66  4 reqCompFieldList.add(reqCompField2);
67  4 reqComponent4.setReqCompFields(reqCompFieldList);
68    }
69   
 
70  4 toggle @Before
71    public void beforeMethod() {
72  4 setupReqComponent1();
73  4 setupReqComponent2();
74  4 setupReqComponent3();
75  4 setupReqComponent4();
76    }
77   
 
78  1 toggle @Test
79    public void testCreateContextMap() throws OperationFailedException {
80  1 Map<String, Object> contextMap = basicContext.createContextMap(reqComponent1);
81  1 Assert.assertNotNull(contextMap);
82  1 Assert.assertTrue(contextMap.containsKey(BasicContextImpl.NL_HELPER_TOKEN));
83  1 Assert.assertTrue(contextMap.containsKey(BasicContextImpl.OPERATOR_TOKEN));
84  1 Assert.assertTrue(contextMap.containsKey(BasicContextImpl.INTEGER_VALUE_TOKEN));
85    }
86   
 
87  1 toggle @Test
88    public void testCreateContextMap_NullTokenValues() throws OperationFailedException {
89  1 Map<String, Object> contextMap = basicContext.createContextMap(reqComponent4);
90  1 Assert.assertNotNull(contextMap);
91  1 Assert.assertFalse(contextMap.containsKey(BasicContextImpl.OPERATOR_TOKEN));
92  1 Assert.assertFalse(contextMap.containsKey(BasicContextImpl.INTEGER_VALUE_TOKEN));
93    }
94   
 
95  1 toggle @Test
96    public void testCreateContextMap_CheckTokenValueDataType_Integer() throws OperationFailedException {
97  1 Map<String, Object> contextMap = basicContext.createContextMap(reqComponent2);
98  1 Object value = contextMap.get(BasicContextImpl.INTEGER_VALUE_TOKEN);
99   
100  1 Assert.assertEquals(Integer.class.getName(), value.getClass().getName());
101  1 Assert.assertEquals("1", value.toString());
102    }
103   
 
104  1 toggle @Test
105    public void testCreateContextMap_CheckTokenValueDataType_NullInteger() throws OperationFailedException {
106  1 Map<String, Object> contextMap = basicContext.createContextMap(reqComponent3);
107  1 Object value = contextMap.get(BasicContextImpl.INTEGER_VALUE_TOKEN);
108   
109  1 Assert.assertEquals(null, value);
110    }
111    }