Clover Coverage Report - Kuali Student 1.1.0-SNAPSHOT (Aggregated)
Coverage timestamp: Tue Feb 15 2011 04:04:07 EST
../../../../../../img/srcFileCovDistChart0.png 48% of files have more coverage
33   110   13   5.5
14   99   0.39   6
6     2.17  
1    
 
  Dictionary2DictionaryComparer       Line # 10 33 0% 13 53 0% 0.0
 
No Tests
 
1    package org.kuali.student.core.dictionary.service;
2   
3    import java.beans.IntrospectionException;
4    import java.util.ArrayList;
5    import java.util.List;
6   
7    import org.kuali.student.core.dictionary.dto.FieldDefinition;
8    import org.kuali.student.core.dictionary.dto.ObjectStructureDefinition;
9   
 
10    public class Dictionary2DictionaryComparer
11    {
12   
13    private ObjectStructureDefinition os1;
14    private ObjectStructureDefinition os2;
15   
 
16  0 toggle public Dictionary2DictionaryComparer (ObjectStructureDefinition os1,
17    ObjectStructureDefinition os2)
18    {
19  0 this.os1 = os1;
20  0 this.os2 = os2;
21    }
22   
 
23  0 toggle public List<String> compare ()
24    {
25  0 return compare (os1, os2);
26   
27    }
28   
 
29  0 toggle private List<String> compare (ObjectStructureDefinition os1,
30    ObjectStructureDefinition os2)
31    {
32  0 List<String> discrepancies = new ArrayList ();
33  0 compare (discrepancies, "Java Object Name", os2.getName (),
34    os1.getName ());
35  0 compare (discrepancies, "hasMetaData", os2.isHasMetaData (),
36    os1.isHasMetaData ());
37  0 compare (discrepancies, "BusinessObjectClass",
38    os2.getBusinessObjectClass (),
39    os1.getBusinessObjectClass ());
40  0 for (FieldDefinition fdDict : os1.getAttributes ())
41    {
42  0 FieldDefinition fdBean = findField (fdDict.getName (), os2);
43  0 if (fdBean == null)
44    {
45  0 discrepancies.add ("Field " + fdDict.getName ()
46    + " is missing from the 1st structure");
47    }
48  0 compare (discrepancies, fdDict.getName () + " dataType",
49    fdDict.getDataType (), fdBean.getDataType ());
50  0 compare (discrepancies, fdDict.getName () + " minOccurs",
51    fdDict.getMinOccurs (), fdBean.getMinOccurs ());
52  0 compare (discrepancies, fdDict.getName () + " maxOccurs",
53    fdDict.getMaxOccurs (), fdBean.getMaxOccurs ());
54    }
55  0 for (FieldDefinition fdBean : os2.getAttributes ())
56    {
57  0 FieldDefinition fdDict = findField (fdBean.getName (), os1);
58  0 if (fdDict == null)
59    {
60  0 discrepancies.add ("Field " + fdBean.getName ()
61    + " missing from the 2nd structure");
62  0 continue;
63    }
64    }
65  0 return discrepancies;
66    }
67   
 
68  0 toggle private FieldDefinition findField (String name, ObjectStructureDefinition os)
69    {
70  0 for (FieldDefinition fd : os.getAttributes ())
71    {
72  0 if (name.equals (fd.getName ()))
73    {
74  0 return fd;
75    }
76    }
77  0 return null;
78    }
79   
 
80  0 toggle private void compare (List<String> discrepancies,
81    String field,
82    Object value1,
83    Object value2)
84    {
85  0 String discrep = compare (field, value1, value2);
86  0 if (discrep != null)
87    {
88  0 discrepancies.add (discrep);
89    }
90    }
91   
 
92  0 toggle private String compare (String field, Object value1, Object value2)
93    {
94  0 if (value1 == null)
95    {
96  0 if (value2 == null)
97    {
98  0 return null;
99    }
100    }
101    else
102    {
103  0 if (value1.equals (value2))
104    {
105  0 return null;
106    }
107    }
108  0 return field + " inconsistent: os1=[" + value1 + "], os2=[" + value2 + "]";
109    }
110    }