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.junit.Assert;
20 import org.junit.Test;
21 import org.kuali.kpme.core.IntegrationTest;
22 import org.kuali.kpme.core.util.TKUtils;
23 import org.kuali.kpme.core.util.ValidationUtils;
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 String institution = "*";
54 String campus = "*";
55 boolean results = PmValidationUtils.validatePositionReportType(prt, institution, campus, aDate.toLocalDate());
56 Assert.assertFalse(results);
57
58 prt = "testPRT";
59 results = PmValidationUtils.validatePositionReportType(prt, institution, campus, aDate.toLocalDate());
60 Assert.assertFalse(results);
61
62 aDate = VALID_DATE;
63 results = PmValidationUtils.validatePositionReportType(prt, institution, campus, aDate.toLocalDate());
64 Assert.assertTrue(results);
65 }
66
67 @Test
68 public void testValidateInstitutionWithPRT() {
69 DateTime aDate = INVALID_DATE;
70 String prt = "nonExist";
71 String institution = "testInst";
72 boolean results = PmValidationUtils.validateInstitutionWithPRT(prt, institution, aDate.toLocalDate());
73 Assert.assertFalse(results);
74
75 prt = "testPRT";
76 results = PmValidationUtils.validateInstitutionWithPRT(prt, institution, aDate.toLocalDate());
77 Assert.assertFalse(results);
78
79 aDate = VALID_DATE;
80 results = PmValidationUtils.validateInstitutionWithPRT(prt, institution, aDate.toLocalDate());
81 Assert.assertTrue(results);
82 }
83
84 @Test
85 public void testValidateCampusWithPRT() {
86 DateTime aDate = INVALID_DATE;
87 String prt = "nonExist";
88 String campus = "testCamp";
89 boolean results = PmValidationUtils.validateCampusWithPRT(prt, campus, aDate.toLocalDate());
90 Assert.assertFalse(results);
91
92 prt = "testPRT";
93 results = PmValidationUtils.validateCampusWithPRT(prt, campus, aDate.toLocalDate());
94 Assert.assertFalse(results);
95
96 aDate = VALID_DATE;
97 results = PmValidationUtils.validateCampusWithPRT(prt, campus, aDate.toLocalDate());
98 Assert.assertFalse(results);
99
100 campus = "BL";
101 results = PmValidationUtils.validateCampusWithPRT(prt, campus, aDate.toLocalDate());
102 Assert.assertTrue(results);
103 }
104
105 @Test
106 public void testValidatePositionReportCategory() {
107 DateTime aDate = INVALID_DATE;
108 String prc = "nonExist";
109 String prt = "nonExist";
110 String institution = "*";
111 String campus = "*";
112 boolean results = PmValidationUtils.validatePositionReportCategory(prc, prt, institution, campus, aDate.toLocalDate());
113 Assert.assertFalse(results);
114
115 prc = "testPRC";
116 results = PmValidationUtils.validatePositionReportCategory(prc, prt, institution, campus, aDate.toLocalDate());
117 Assert.assertFalse(results);
118
119 aDate = VALID_DATE;
120 results = PmValidationUtils.validatePositionReportCategory(prc, prt, institution, campus, aDate.toLocalDate());
121 Assert.assertFalse(results);
122
123 prt = "testPRT";
124 results = PmValidationUtils.validatePositionReportCategory(prc, prt, institution, campus, aDate.toLocalDate());
125 Assert.assertTrue(results);
126 }
127
128 @Test
129 public void testValidatePositionReportSubCat() {
130 DateTime aDate = INVALID_DATE;
131 String prsc = "nonExist";
132 String institution = "*";
133 String campus = "*";
134 boolean results = PmValidationUtils.validatePositionReportSubCat(prsc, institution, campus, aDate.toLocalDate());
135 Assert.assertFalse(results);
136
137 prsc = "testPRSC";
138 results = PmValidationUtils.validatePositionReportSubCat(prsc, institution, campus, aDate.toLocalDate());
139 Assert.assertFalse(results);
140
141 aDate = VALID_DATE;
142 institution = "nonExist";
143 results = PmValidationUtils.validatePositionReportSubCat(prsc, institution, campus, aDate.toLocalDate());
144 Assert.assertFalse(results);
145
146 institution = "testInst";
147 campus = "nonExist";
148 results = PmValidationUtils.validatePositionReportSubCat(prsc, institution, campus, aDate.toLocalDate());
149 Assert.assertFalse(results);
150
151 campus = "BL";
152 results = PmValidationUtils.validatePositionReportSubCat(prsc, institution, campus, aDate.toLocalDate());
153 Assert.assertTrue(results);
154 }
155
156
157 @Test
158 public void testValidatePstnRptGrp() {
159 DateTime aDate = INVALID_DATE;
160 String prg = "nonExist";
161 String institution = "*";
162 String campus = "*";
163 boolean results = PmValidationUtils.validatePstnRptGrp(prg, institution, campus, aDate.toLocalDate());
164 Assert.assertFalse(results);
165
166 prg = "testPRG";
167 results = PmValidationUtils.validatePstnRptGrp(prg, institution, campus, aDate.toLocalDate()); ;
168 Assert.assertFalse(results);
169
170 aDate = VALID_DATE;
171 institution = "nonExist";
172 results = PmValidationUtils.validatePstnRptGrp(prg, institution, campus, aDate.toLocalDate());
173 Assert.assertFalse(results);
174
175 institution = "testInst";
176 campus = "nonExist";
177 results = PmValidationUtils.validatePstnRptGrp(prg, institution, campus, aDate.toLocalDate());
178 Assert.assertFalse(results);
179
180 campus = "BL";
181 results = PmValidationUtils.validatePstnRptGrp(prg, institution, campus, aDate.toLocalDate());
182 Assert.assertTrue(results);
183 }
184 }