1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.pm.validation;
17
18 import org.joda.time.DateTime;
19 import org.joda.time.LocalDate;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.kuali.kpme.core.IntegrationTest;
23 import org.kuali.kpme.core.util.TKUtils;
24 import org.kuali.kpme.pm.PMIntegrationTestCase;
25 import org.kuali.kpme.pm.util.PmValidationUtils;
26
27 @IntegrationTest
28 public class PmValidationUtilsTest extends PMIntegrationTestCase {
29
30 private static DateTime INVALID_DATE = new DateTime(2011, 7, 7, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
31 private static DateTime VALID_DATE = new DateTime(2012, 7, 7, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
32
33 @Test
34 public void testValidateCampus() {
35 String campus = "*";
36 boolean results = PmValidationUtils.validateCampus(campus);
37 Assert.assertTrue(results);
38
39 campus = "nonExist";
40 results = PmValidationUtils.validateCampus(campus);
41 Assert.assertFalse(results);
42
43 campus = "TS";
44 results = PmValidationUtils.validateCampus(campus);
45 Assert.assertTrue(results);
46
47 }
48
49 @Test
50 public void testValidatePositionReportType() {
51 DateTime aDate = INVALID_DATE;
52 String prt = "nonExist";
53
54 boolean results = PmValidationUtils.validatePositionReportType(prt, aDate.toLocalDate());
55 Assert.assertFalse(results);
56
57 prt = "testPRT";
58 results = PmValidationUtils.validatePositionReportType(prt, aDate.toLocalDate());
59 Assert.assertFalse(results);
60
61 aDate = VALID_DATE;
62 results = PmValidationUtils.validatePositionReportType(prt, aDate.toLocalDate());
63 Assert.assertTrue(results);
64 }
65
66 @Test
67 public void testValidatePayGradeWithSalaryGroup() {
68 DateTime aDate = INVALID_DATE;
69 String payGrade = "nonExist";
70 String salaryGroup = "*";
71 boolean results = PmValidationUtils.validatePayGradeWithSalaryGroup(salaryGroup, payGrade, aDate.toLocalDate());
72 Assert.assertFalse(results);
73
74 payGrade = "T";
75 results = PmValidationUtils.validatePayGradeWithSalaryGroup(salaryGroup, payGrade, aDate.toLocalDate());
76 Assert.assertFalse(results);
77
78 aDate = VALID_DATE;
79 salaryGroup = "nonExist";
80 results = PmValidationUtils.validatePayGradeWithSalaryGroup(salaryGroup, payGrade, aDate.toLocalDate());
81 Assert.assertFalse(results);
82
83 salaryGroup = "testSalGrp";
84 results = PmValidationUtils.validatePayGradeWithSalaryGroup(salaryGroup, payGrade, aDate.toLocalDate());
85 Assert.assertTrue(results);
86 }
87
88 @Test
89 public void testValidatePositionReportCategory() {
90 DateTime aDate = INVALID_DATE;
91 String prc = "nonExist";
92 String prt = "nonExist";
93
94
95 boolean results = PmValidationUtils.validatePositionReportCategory(prc, prt, aDate.toLocalDate());
96 Assert.assertFalse(results);
97
98 prc = "testPRC";
99 results = PmValidationUtils.validatePositionReportCategory(prc, prt, aDate.toLocalDate());
100 Assert.assertFalse(results);
101
102 aDate = VALID_DATE;
103 results = PmValidationUtils.validatePositionReportCategory(prc, prt, aDate.toLocalDate());
104 Assert.assertFalse(results);
105
106 prt = "testPRT";
107 results = PmValidationUtils.validatePositionReportCategory(prc, prt, aDate.toLocalDate());
108 Assert.assertTrue(results);
109 }
110
111 @Test
112 public void testValidatePositionReportSubCat() {
113 DateTime aDate = INVALID_DATE;
114 String prsc = "nonExist";
115
116 boolean results = PmValidationUtils.validatePositionReportSubCat(prsc,aDate.toLocalDate());
117 Assert.assertFalse(results);
118
119 prsc = "testPRSC";
120 results = PmValidationUtils.validatePositionReportSubCat(prsc, aDate.toLocalDate());
121 Assert.assertFalse(results);
122
123 aDate = VALID_DATE;
124 results = PmValidationUtils.validatePositionReportSubCat(prsc, aDate.toLocalDate());
125 Assert.assertTrue(results);
126 }
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 @Test
150 public void testValidatePositionQualificationValue() {
151 String qValue = "nonExist";
152 boolean results = PmValidationUtils.validatePositionQualificationValue(qValue);
153 Assert.assertFalse(results);
154
155 qValue = "existing";
156 results = PmValidationUtils.validatePositionQualificationValue(qValue);
157 Assert.assertTrue(results);
158 }
159
160 @Test
161 public void testValidateAffiliation() {
162 DateTime aDate = INVALID_DATE;
163 String deptAffl = "nonExist";
164 boolean results = PmValidationUtils.validateAffiliation(deptAffl, aDate.toLocalDate());
165 Assert.assertFalse(results);
166
167 deptAffl = "testType";
168 results = PmValidationUtils.validateAffiliation(deptAffl, aDate.toLocalDate());
169 Assert.assertFalse(results);
170
171 results = PmValidationUtils.validateAffiliation(deptAffl, LocalDate.now());
172 Assert.assertTrue(results);
173
174 }
175
176 @Test
177 public void testValidatePositionType(){
178 DateTime aDate = INVALID_DATE;
179 String pType = "nonExist";
180 String institution ="*";
181 String campus = "*";
182 boolean results = PmValidationUtils.validatePositionType(pType,aDate.toLocalDate());
183 Assert.assertFalse(results);
184 }
185
186 @Test
187 public void testValidatePositionAppointmentType() {
188
189 LocalDate asOfDate = new LocalDate(2010,1,1);
190
191
192 boolean results = PmValidationUtils.validatePositionAppointmentType("noWildCard","UGA-ATHENS",asOfDate);
193 Assert.assertTrue(results);
194
195 }
196 }