View Javadoc
1   package org.kuali.student.core.ges.dto;
2   
3   
4   import org.junit.Test;
5   import org.kuali.rice.core.api.util.type.KualiDecimal;
6   import org.kuali.student.r2.common.dto.AmountInfo;
7   import org.kuali.student.r2.common.dto.CurrencyAmountInfo;
8   import org.kuali.student.r2.common.dto.TimeAmountInfo;
9   import org.kuali.student.r2.common.dto.TimeOfDayInfo;
10  
11  import java.util.Date;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertFalse;
15  import static org.junit.Assert.assertTrue;
16  
17  
18  public class TestValueInfo {
19  
20      @Test
21      public void testBooleanValues() {
22          ValueInfo value = new ValueInfo();
23          value.setBooleanValue(true);
24  
25          assertTrue(value.getBooleanValue());
26  
27          value.setBooleanValue(false);
28          assertFalse(value.getBooleanValue());
29      }
30  
31      @Test
32      public void testDateValues() {
33          ValueInfo value = new ValueInfo();
34          Date date = new Date();
35          value.setDateValue(date);
36  
37          assertEquals(date, value.getDateValue());
38      }
39  
40      @Test
41      public void testNumericValues() {
42          ValueInfo value = new ValueInfo();
43          value.setNumericValue(123456789L);
44  
45          assertEquals(Long.valueOf(123456789L), value.getNumericValue());
46  
47          value.setNumericValue(-123456789L);
48  
49          assertEquals(Long.valueOf(-123456789L), value.getNumericValue());
50  
51          value.setNumericValue(0L);
52  
53          assertEquals(Long.valueOf(0L), value.getNumericValue());
54      }
55  
56      @Test
57      public void testDecimalValues() {
58          ValueInfo value = new ValueInfo();
59          KualiDecimal decimal = new KualiDecimal(5.5D);
60          value.setDecimalValue(decimal);
61  
62          assertEquals(decimal, value.getDecimalValue());
63  
64          decimal = KualiDecimal.ZERO;
65          value.setDecimalValue(decimal);
66  
67          assertEquals(decimal, value.getDecimalValue());
68  
69          decimal = new KualiDecimal(-5.05D);
70          value.setDecimalValue(decimal);
71  
72          assertEquals(decimal, value.getDecimalValue());
73      }
74  
75      @Test
76      public void testAmountValues() {
77          ValueInfo value = new ValueInfo();
78          AmountInfo info = new AmountInfo();
79          info.setUnitQuantity("10.5");
80          info.setUnitTypeKey("kuali.org.amount.feet");
81          value.setAmountValue(info);
82  
83          assertEquals(info.getUnitQuantity(), value.getAmountValue().getUnitQuantity());
84          assertEquals(info.getUnitTypeKey(), value.getAmountValue().getUnitTypeKey());
85      }
86  
87      @Test
88      public void testCurrencyAmountValues() {
89          ValueInfo value = new ValueInfo();
90          CurrencyAmountInfo info = new CurrencyAmountInfo();
91          info.setCurrencyQuantity(42);
92          info.setCurrencyTypeKey("kuali.org.rupee");
93          value.setCurrencyAmountValue(info);
94  
95          assertEquals(info.getCurrencyQuantity(), value.getCurrencyAmountValue().getCurrencyQuantity());
96          assertEquals(info.getCurrencyTypeKey(), value.getCurrencyAmountValue().getCurrencyTypeKey());
97  
98          info = new CurrencyAmountInfo();
99          info.setCurrencyQuantity(0);
100         info.setCurrencyTypeKey("kuali.org.rupee");
101         value.setCurrencyAmountValue(info);
102 
103         assertEquals(info.getCurrencyQuantity(), value.getCurrencyAmountValue().getCurrencyQuantity());
104         assertEquals(info.getCurrencyTypeKey(), value.getCurrencyAmountValue().getCurrencyTypeKey());
105 
106         info.setCurrencyQuantity(-238900);
107         info.setCurrencyTypeKey("kuali.org.rupee");
108         value.setCurrencyAmountValue(info);
109 
110         assertEquals(info.getCurrencyQuantity(), value.getCurrencyAmountValue().getCurrencyQuantity());
111         assertEquals(info.getCurrencyTypeKey(), value.getCurrencyAmountValue().getCurrencyTypeKey());
112     }
113 
114     @Test
115     public void testTimeAmountValues() {
116         ValueInfo value = new ValueInfo();
117         TimeAmountInfo info = new TimeAmountInfo();
118         info.setAtpDurationTypeKey("org.kuali.time.eon");
119         info.setTimeQuantity(35);
120 
121         value.setTimeAmountValue(info);
122         assertEquals(info.getAtpDurationTypeKey(), value.getTimeAmountValue().getAtpDurationTypeKey());
123         assertEquals(info.getTimeQuantity(), value.getTimeAmountValue().getTimeQuantity());
124 
125         info = new TimeAmountInfo();
126         info.setAtpDurationTypeKey("org.kuali.time.weeks");
127         info.setTimeQuantity(0);
128 
129         value.setTimeAmountValue(info);
130         assertEquals(info.getAtpDurationTypeKey(), value.getTimeAmountValue().getAtpDurationTypeKey());
131         assertEquals(info.getTimeQuantity(), value.getTimeAmountValue().getTimeQuantity());
132     }
133 
134     @Test
135     public void testTimeOfDayValues() {
136         ValueInfo value = new ValueInfo();
137         TimeOfDayInfo info = new TimeOfDayInfo(1,2,3);
138         value.setTimeOfDayValue(info);
139 
140         assertEquals(info, value.getTimeOfDayValue());
141 
142         info = new TimeOfDayInfo(1);
143         value.setTimeOfDayValue(info);
144 
145         assertEquals(info, value.getTimeOfDayValue());
146 
147         info = new TimeOfDayInfo(0,0,0);
148         value.setTimeOfDayValue(info);
149 
150         assertEquals(info, value.getTimeOfDayValue());
151 
152     }
153 
154     @Test
155     public void testStringValues() {
156         ValueInfo value = new ValueInfo();
157         value.setStringValue("testValue");
158 
159         assertEquals("testValue", value.getStringValue());
160 
161     }
162 }