1
2
3
4
5 package org.kuali.student.enrollment.class1.lrc.service.impl;
6
7 import java.sql.Timestamp;
8 import java.util.ArrayList;
9 import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
10 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
11 import org.kuali.student.r2.common.exceptions.DependentObjectsExistException;
12 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
13 import org.kuali.student.r2.common.exceptions.MissingParameterException;
14 import org.kuali.student.r2.common.exceptions.OperationFailedException;
15 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
16 import org.kuali.student.r2.common.exceptions.ReadOnlyException;
17 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
21 import static org.junit.Assert.fail;
22
23 import java.util.Date;
24
25 import java.util.List;
26 import javax.annotation.Resource;
27
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.kuali.student.enrollment.test.util.AttributeTester;
32 import org.kuali.student.enrollment.test.util.FloatAsStringTester;
33 import org.kuali.student.enrollment.test.util.KeyEntityTester;
34 import org.kuali.student.enrollment.test.util.ListOfStringTester;
35 import org.kuali.student.enrollment.test.util.MetaTester;
36 import org.kuali.student.enrollment.test.util.TimeTester;
37 import org.kuali.student.r2.common.dto.ContextInfo;
38 import org.kuali.student.r2.common.dto.StatusInfo;
39 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
40 import org.kuali.student.r2.common.util.RichTextHelper;
41 import org.kuali.student.r2.lum.util.constants.LrcServiceConstants;
42 import org.kuali.student.r2.lum.lrc.dto.ResultScaleInfo;
43 import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo;
44 import org.kuali.student.r2.lum.lrc.dto.ResultValueRangeInfo;
45 import org.kuali.student.r2.lum.lrc.dto.ResultValuesGroupInfo;
46 import org.kuali.student.r2.lum.lrc.infc.ResultValueRange;
47 import org.kuali.student.r2.lum.lrc.service.LRCService;
48 import org.springframework.test.context.ContextConfiguration;
49 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
50
51 @RunWith(SpringJUnit4ClassRunner.class)
52 @ContextConfiguration(locations = {"classpath:lrc-mock-service-test-context.xml"})
53 public class TestLrcServiceMockImpl {
54
55 public LRCService getLRCService() {
56 return lrcService;
57 }
58
59 public void setLRCService(LRCService lrcService) {
60 this.lrcService = lrcService;
61 }
62 @Resource
63 private LRCService lrcService;
64 public static String principalId = "123";
65 public ContextInfo callContext = null;
66
67 @Before
68 public void setUp() {
69 principalId = "123";
70 callContext = new ContextInfo();
71 callContext.setPrincipalId(principalId);
72
73
74
75
76
77 }
78
79 @Test
80 public void testCrud()
81 throws DataValidationErrorException,
82 DoesNotExistException,
83 InvalidParameterException,
84 MissingParameterException,
85 OperationFailedException,
86 PermissionDeniedException,
87 ReadOnlyException,
88 VersionMismatchException,
89 AlreadyExistsException,
90 DependentObjectsExistException {
91
92 ResultScaleInfo expected = new ResultScaleInfo();
93 expected.setKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
94 expected.setTypeKey(LrcServiceConstants.RESULT_SCALE_TYPE_KEY_GRADE);
95 expected.setStateKey(LrcServiceConstants.RESULT_SCALE_STATE_APPROVED);
96 expected.setEffectiveDate(new Date());
97 expected.setExpirationDate(new Date(new Date().getTime() + 1000));
98 expected.setName("A-F Letter Graded Scale");
99 expected.setDescr(new RichTextHelper().fromPlain("Letter Graded Scale description"));
100 new AttributeTester().add2ForCreate(expected.getAttributes());
101 ResultScaleInfo actual = lrcService.createResultScale(expected.getTypeKey(), expected,
102 callContext);
103 assertEquals(expected.getKey(), actual.getKey());
104 new KeyEntityTester().check(expected, actual);
105 checkRange(expected.getResultValueRange(), actual.getResultValueRange());
106 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
107 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
108 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
109 new MetaTester().checkAfterCreate(actual.getMeta());
110
111
112 try {
113 lrcService.createResultScale(expected.getTypeKey(), expected, callContext);
114 fail("should have gotten an already exists exception");
115 } catch (AlreadyExistsException e) {
116
117 }
118
119
120 expected = actual;
121 actual = lrcService.getResultScale(actual.getKey(), callContext);
122 assertEquals(expected.getKey(), actual.getKey());
123 new KeyEntityTester().check(expected, actual);
124 checkRange(expected.getResultValueRange(), actual.getResultValueRange());
125 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
126 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
127 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
128 new MetaTester().checkAfterGet(expected.getMeta(), actual.getMeta());
129
130
131 expected = actual;
132 expected.setName(expected.getName() + " updated");
133 expected.setDescr(new RichTextHelper().fromPlain(expected.getDescr().getPlain() + " updated"));
134 expected.setEffectiveDate(new Timestamp(expected.getEffectiveDate().getTime() - 2000));
135 expected.setExpirationDate(new Timestamp(expected.getExpirationDate().getTime() + 2000));
136
137
138
139 new AttributeTester().delete1Update1Add1ForUpdate(expected.getAttributes());
140 actual = lrcService.updateResultScale(expected.getKey(), expected, callContext);
141 assertEquals(expected.getKey(), actual.getKey());
142 new KeyEntityTester().check(expected, actual);
143 checkRange(expected.getResultValueRange(), actual.getResultValueRange());
144 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
145 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
146 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
147 new MetaTester().checkAfterUpdate(expected.getMeta(), actual.getMeta());
148
149
150 expected = actual;
151 actual = lrcService.getResultScale(actual.getKey(), callContext);
152 assertEquals(expected.getKey(), actual.getKey());
153 new KeyEntityTester().check(expected, actual);
154 checkRange(expected.getResultValueRange(), actual.getResultValueRange());
155 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
156 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
157 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
158 new MetaTester().checkAfterGet(expected.getMeta(), actual.getMeta());
159
160 ResultScaleInfo letterGradedScale = actual;
161
162
163 ResultScaleInfo creditScale = new ResultScaleInfo();
164 creditScale.setKey(LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE);
165 creditScale.setTypeKey(LrcServiceConstants.RESULT_SCALE_TYPE_KEY_CREDIT);
166 creditScale.setStateKey(LrcServiceConstants.RESULT_SCALE_STATE_APPROVED);
167 creditScale.setEffectiveDate(new Date());
168 creditScale.setExpirationDate(new Date(new Date().getTime() + 1000));
169 creditScale.setName("Degree Credit");
170 creditScale.setDescr(new RichTextHelper().fromPlain("Degree Credit"));
171 creditScale = lrcService.createResultScale(creditScale.getTypeKey(), creditScale,
172 callContext);
173
174
175 expected = new ResultScaleInfo();
176 expected.setKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_PERCENTAGE);
177 expected.setTypeKey(LrcServiceConstants.RESULT_SCALE_TYPE_KEY_GRADE);
178 expected.setStateKey(LrcServiceConstants.RESULT_SCALE_STATE_APPROVED);
179 expected.setEffectiveDate(new Date());
180 expected.setExpirationDate(new Date(new Date().getTime() + 1000));
181 expected.setName("Pass/Fail Scale");
182 expected.setDescr(new RichTextHelper().fromPlain("pass/fail scale"));
183 ResultValueRangeInfo range = new ResultValueRangeInfo();
184 range.setMinValue("0");
185 range.setMaxValue("99");
186 range.setIncrement("1");
187 expected.setResultValueRange(range);
188 actual = lrcService.createResultScale(expected.getTypeKey(), expected,
189 callContext);
190 checkRange(expected.getResultValueRange(), actual.getResultValueRange());
191
192
193 expected = actual;
194 expected.getResultValueRange().setMinValue("1");
195 expected.getResultValueRange().setMaxValue("100");
196 expected.getResultValueRange().setIncrement(".1");
197 actual = lrcService.updateResultScale(expected.getKey(), expected, callContext);
198 assertEquals(expected.getKey(), actual.getKey());
199 new KeyEntityTester().check(expected, actual);
200 checkRange(expected.getResultValueRange(), actual.getResultValueRange());
201 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
202 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
203 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
204 new MetaTester().checkAfterUpdate(expected.getMeta(), actual.getMeta());
205 ResultScaleInfo percentScale = actual;
206
207
208 List<String> keys = new ArrayList<String>();
209 keys.add(letterGradedScale.getKey());
210 keys.add(percentScale.getKey());
211 keys.add(creditScale.getKey());
212 List<ResultScaleInfo> both = lrcService.getResultScalesByKeys(keys, callContext);
213 assertEquals(keys.size(), both.size());
214 for (ResultScaleInfo info : both) {
215 if (!keys.remove(info.getKey())) {
216 fail(info.getKey() + " was not in the return list");
217 }
218 }
219 assertEquals(0, keys.size());
220
221
222
223 keys = lrcService.getResultScaleKeysByType(LrcServiceConstants.RESULT_SCALE_TYPE_KEY_GRADE, callContext);
224 assertEquals(2, keys.size());
225 if (!keys.remove(letterGradedScale.getKey())) {
226 fail("does not contain " + letterGradedScale.getKey());
227 }
228 if (!keys.remove(percentScale.getKey())) {
229 fail("does not contain " + percentScale.getKey());
230 }
231
232
233 ResultScaleInfo passFailScale = new ResultScaleInfo();
234 passFailScale.setKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_PF);
235 passFailScale.setTypeKey(LrcServiceConstants.RESULT_SCALE_TYPE_KEY_GRADE);
236 passFailScale.setStateKey(LrcServiceConstants.RESULT_SCALE_STATE_APPROVED);
237 passFailScale.setEffectiveDate(new Date());
238 passFailScale.setExpirationDate(new Date(new Date().getTime() + 1000));
239 passFailScale.setName("Pass/Fail");
240 passFailScale.setDescr(new RichTextHelper().fromPlain("Pass Fail"));
241 passFailScale = lrcService.createResultScale(passFailScale.getTypeKey(), passFailScale,
242 callContext);
243
244 this.testCrudResultValue();
245
246
247 StatusInfo status = lrcService.deleteResultScale(letterGradedScale.getKey(), callContext);
248 assertNotNull(status);
249 assertTrue(status.getIsSuccess());
250 try {
251 actual = lrcService.getResultScale(letterGradedScale.getKey(), callContext);
252 fail("Did not receive DoesNotExistException when attempting to get already-deleted Entity");
253 } catch (DoesNotExistException dnee) {
254
255 }
256 status = lrcService.deleteResultScale(percentScale.getKey(), callContext);
257 assertNotNull(status);
258 assertTrue(status.getIsSuccess());
259 try {
260 actual = lrcService.getResultScale(percentScale.getKey(), callContext);
261 fail("Did not receive DoesNotExistException when attempting to get already-deleted Entity");
262 } catch (DoesNotExistException dnee) {
263
264 }
265 status = lrcService.deleteResultScale(passFailScale.getKey(), callContext);
266 assertNotNull(status);
267 assertTrue(status.getIsSuccess());
268 try {
269 actual = lrcService.getResultScale(passFailScale.getKey(), callContext);
270 fail("Did not receive DoesNotExistException when attempting to get already-deleted Entity");
271 } catch (DoesNotExistException dnee) {
272
273 }
274
275 }
276
277 private void checkRange(ResultValueRangeInfo expected,
278 ResultValueRangeInfo actual) {
279 if (expected == null && actual == null) {
280 return;
281 }
282 if (expected == null) {
283 fail("expected range was null but actual had a structure with fields=" + toString(actual));
284 }
285 if (actual == null) {
286 fail("actual range was null but expected had a structure with fields=" + toString(expected));
287 }
288 assertEquals(expected.getMinValue(), expected.getMinValue());
289 assertEquals(expected.getMaxValue(), expected.getMaxValue());
290 assertEquals(expected.getIncrement(), expected.getIncrement());
291 }
292
293 private String toString(ResultValueRange range) {
294 return range.getMinValue() + " to " + range.getMaxValue() + " + " + range.getIncrement();
295 }
296
297 public void testCrudResultValue()
298 throws DataValidationErrorException,
299 DoesNotExistException,
300 InvalidParameterException,
301 MissingParameterException,
302 OperationFailedException,
303 PermissionDeniedException,
304 ReadOnlyException,
305 VersionMismatchException,
306 AlreadyExistsException,
307 DependentObjectsExistException {
308
309
310 ResultValueInfo expected = new ResultValueInfo();
311 expected.setKey(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_A);
312 expected.setTypeKey(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE);
313 expected.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
314 expected.setEffectiveDate(new Date());
315 expected.setExpirationDate(new Date(new Date().getTime() + 1000));
316 expected.setName("Grade A+");
317 expected.setDescr(new RichTextHelper().fromPlain("value A+ description"));
318 expected.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
319 expected.setValue("A+");
320 expected.setNumericValue("4.5");
321 new AttributeTester().add2ForCreate(expected.getAttributes());
322 ResultValueInfo actual = lrcService.createResultValue(expected.getResultScaleKey(), expected.getTypeKey(), expected,
323 callContext);
324 assertEquals(expected.getKey(), actual.getKey());
325 new KeyEntityTester().check(expected, actual);
326 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
327 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
328 assertEquals(expected.getResultScaleKey(), actual.getResultScaleKey());
329 assertEquals (expected.getValue(), actual.getValue());
330 new FloatAsStringTester ().check(expected.getNumericValue(), actual.getNumericValue());
331 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
332 new MetaTester().checkAfterCreate(actual.getMeta());
333
334
335 try {
336 lrcService.createResultValue(expected.getResultScaleKey(), expected.getTypeKey(), expected, callContext);
337 fail("should have gotten an already exists exception");
338 } catch (AlreadyExistsException e) {
339
340 }
341
342 expected = actual;
343 actual = lrcService.getResultValue(actual.getKey(), callContext);
344 assertEquals(expected.getKey(), actual.getKey());
345 new KeyEntityTester().check(expected, actual);
346 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
347 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
348 assertEquals(expected.getResultScaleKey(), actual.getResultScaleKey());
349 assertEquals(expected.getValue(), actual.getValue());
350 new FloatAsStringTester ().check(expected.getNumericValue(), actual.getNumericValue());
351 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
352 new MetaTester().checkAfterGet(expected.getMeta(), actual.getMeta());
353
354
355 expected = actual;
356 expected.setName("Grade A");
357 expected.setEffectiveDate(new Timestamp(expected.getEffectiveDate().getTime() - 2000));
358 expected.setExpirationDate(new Timestamp(expected.getExpirationDate().getTime() + 2000));
359 expected.setDescr(new RichTextHelper().fromPlain("Grade A description"));
360 expected.setValue("A");
361 expected.setValue("4.0");
362 new AttributeTester().delete1Update1Add1ForUpdate(expected.getAttributes());
363 actual = lrcService.updateResultValue(expected.getKey(), expected, callContext);
364 assertEquals(expected.getKey(), actual.getKey());
365 new KeyEntityTester().check(expected, actual);
366 assertEquals(expected.getResultScaleKey(), actual.getResultScaleKey());
367 assertEquals(expected.getValue(), actual.getValue());
368 new FloatAsStringTester ().check(expected.getNumericValue(), actual.getNumericValue());
369 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
370 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
371 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
372 new MetaTester().checkAfterUpdate(expected.getMeta(), actual.getMeta());
373
374
375 expected = actual;
376 actual = lrcService.getResultValue(actual.getKey(), callContext);
377 assertEquals(expected.getKey(), actual.getKey());
378 new KeyEntityTester().check(expected, actual);
379 assertEquals(expected.getResultScaleKey(), actual.getResultScaleKey());
380 assertEquals(expected.getValue(), actual.getValue());
381 new FloatAsStringTester ().check(expected.getNumericValue(), actual.getNumericValue());
382 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
383 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
384 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
385 new MetaTester().checkAfterGet(expected.getMeta(), actual.getMeta());
386
387 ResultValueInfo gradeA = actual;
388
389
390 ResultValueInfo gradeB = new ResultValueInfo();
391 gradeB.setKey(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_B);
392 gradeB.setTypeKey(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE);
393 gradeB.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
394 gradeB.setEffectiveDate(new Date());
395 gradeB.setExpirationDate(new Date(new Date().getTime() + 1000));
396 gradeB.setName("B grade");
397 gradeB.setDescr(new RichTextHelper().fromPlain("value B description"));
398 gradeB.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
399 gradeB.setValue("B");
400 gradeB.setNumericValue("3.0");
401 gradeB = lrcService.createResultValue(gradeB.getResultScaleKey(), gradeB.getTypeKey(), gradeB,
402 callContext);
403
404 List<String> keys = new ArrayList<String>();
405 keys.add(actual.getKey());
406 keys.add(gradeB.getKey());
407 List<ResultValueInfo> both = lrcService.getResultValuesByKeys(keys, callContext);
408 assertEquals(keys.size(), both.size());
409 for (ResultValueInfo info : both) {
410 if (!keys.remove(info.getKey())) {
411 fail(info.getKey() + " was not in the return list");
412 }
413 }
414 assertEquals(0, keys.size());
415
416 keys = lrcService.getResultValueKeysByType(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE, callContext);
417 assertEquals(2, keys.size());
418 if (!keys.remove(actual.getKey())) {
419 fail("does ot contain " + actual.getKey());
420 }
421 if (!keys.remove(gradeB.getKey())) {
422 fail("does ot contain " + gradeB.getKey());
423 }
424
425
426
427
428 ResultValueInfo gradeC = new ResultValueInfo();
429 gradeC.setKey(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_C);
430 gradeC.setTypeKey(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE);
431 gradeC.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
432 gradeC.setEffectiveDate(new Date());
433 gradeC.setExpirationDate(new Date(new Date().getTime() + 1000));
434 gradeC.setName("value C");
435 gradeC.setDescr(new RichTextHelper().fromPlain("value C description"));
436 gradeC.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
437 gradeC.setValue("C");
438 gradeC.setNumericValue("2.0");
439 gradeC = lrcService.createResultValue(gradeC.getResultScaleKey(), gradeC.getTypeKey(), gradeC, callContext);
440
441
442 ResultValueInfo gradeD = new ResultValueInfo();
443 gradeD.setKey(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_D);
444 gradeD.setTypeKey(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE);
445 gradeD.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
446 gradeD.setEffectiveDate(new Date());
447 gradeD.setExpirationDate(new Date(new Date().getTime() + 1000));
448 gradeD.setName("value D");
449 gradeD.setDescr(new RichTextHelper().fromPlain("value D description"));
450 gradeD.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
451 gradeD.setValue("D");
452 gradeD.setNumericValue("1.0");
453 gradeD = lrcService.createResultValue(gradeD.getResultScaleKey(), gradeD.getTypeKey(), gradeD, callContext);
454
455
456 ResultValueInfo gradeF = new ResultValueInfo();
457 gradeF.setKey(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_F);
458 gradeF.setTypeKey(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE);
459 gradeF.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
460 gradeF.setEffectiveDate(new Date());
461 gradeF.setExpirationDate(new Date(new Date().getTime() + 1000));
462 gradeF.setName("value F");
463 gradeF.setDescr(new RichTextHelper().fromPlain("value F description"));
464 gradeF.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
465 gradeF.setValue("F");
466 gradeF.setNumericValue("0.0");
467 gradeF = lrcService.createResultValue(gradeF.getResultScaleKey(), gradeF.getTypeKey(), gradeF, callContext);
468
469
470 ResultValueInfo gradePfP = new ResultValueInfo();
471 gradePfP.setKey(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_P);
472 gradePfP.setTypeKey(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE);
473 gradePfP.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
474 gradePfP.setEffectiveDate(new Date());
475 gradePfP.setExpirationDate(new Date(new Date().getTime() + 1000));
476 gradePfP.setName("value PF P");
477 gradePfP.setDescr(new RichTextHelper().fromPlain("value P description"));
478 gradePfP.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_PF);
479 gradePfP.setValue("P");
480 gradePfP.setNumericValue("1.0");
481 gradePfP = lrcService.createResultValue(gradePfP.getResultScaleKey(), gradePfP.getTypeKey(), gradePfP, callContext);
482
483
484 ResultValueInfo gradePfF = new ResultValueInfo();
485 gradePfF.setKey(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_F);
486 gradePfF.setTypeKey(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE);
487 gradePfF.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
488 gradePfF.setEffectiveDate(new Date());
489 gradePfF.setExpirationDate(new Date(new Date().getTime() + 1000));
490 gradePfF.setName("value F");
491 gradePfF.setDescr(new RichTextHelper().fromPlain("value F description"));
492 gradePfF.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_PF);
493 gradePfF.setValue("F");
494 gradePfF.setNumericValue("0.0");
495 gradePfF = lrcService.createResultValue(gradePfF.getResultScaleKey(), gradePfF.getTypeKey(), gradePfF, callContext);
496
497
498 actual = lrcService.getResultValueForScaleAndValue(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_PF, "F", callContext);
499 assertEquals(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_F, actual.getKey());
500 try {
501 lrcService.getResultValueForScaleAndValue(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER, "P", callContext);
502 fail("should not have found a P value in a letter grading scale");
503 } catch (DoesNotExistException ex) {
504
505 }
506 assertEquals(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_F, actual.getKey());
507
508 this.testCrudResultValuesGroup();
509
510
511 StatusInfo status = lrcService.deleteResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_A, callContext);
512 assertNotNull(status);
513 assertTrue(status.getIsSuccess());
514 try {
515 actual = lrcService.getResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_A, callContext);
516 fail("Did not receive DoesNotExistException when attempting to get already-deleted Entity");
517 } catch (DoesNotExistException dnee) {
518
519 }
520 status = lrcService.deleteResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_B, callContext);
521 assertNotNull(status);
522 assertTrue(status.getIsSuccess());
523 try {
524 actual = lrcService.getResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_B, callContext);
525 fail("Did not receive DoesNotExistException when attempting to get already-deleted Entity");
526 } catch (DoesNotExistException dnee) {
527
528 }
529 status = lrcService.deleteResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_C, callContext);
530 status = lrcService.deleteResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_D, callContext);
531 status = lrcService.deleteResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_F, callContext);
532 status = lrcService.deleteResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_P, callContext);
533 status = lrcService.deleteResultValue(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_F, callContext);
534 }
535
536 public void testCrudResultValuesGroup()
537 throws DataValidationErrorException,
538 DoesNotExistException,
539 InvalidParameterException,
540 MissingParameterException,
541 OperationFailedException,
542 PermissionDeniedException,
543 ReadOnlyException,
544 VersionMismatchException,
545 AlreadyExistsException {
546
547
548 ResultValuesGroupInfo expected = new ResultValuesGroupInfo();
549
550 expected.setKey(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PASSING_TRANSLATION);
551 expected.setTypeKey(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE);
552 expected.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
553 expected.setEffectiveDate(new Date());
554 expected.setExpirationDate(new Date(new Date().getTime() + 1000));
555 expected.setName("Passing Letter Grades");
556 expected.setDescr(new RichTextHelper().fromPlain("Grades that are considered passing on an A-F letter scale"));
557 expected.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
558 expected.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_A);
559 expected.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_B);
560 expected.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_C);
561 expected.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_D);
562 expected.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_F);
563 new AttributeTester().add2ForCreate(expected.getAttributes());
564 ResultValuesGroupInfo actual = lrcService.createResultValuesGroup(expected.getResultScaleKey(), expected.getTypeKey(),
565 expected,
566 callContext);
567 assertEquals(expected.getKey(), actual.getKey());
568 new KeyEntityTester().check(expected, actual);
569 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
570 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
571 assertEquals(expected.getResultScaleKey(), actual.getResultScaleKey());
572 new ListOfStringTester().check(expected.getResultValueKeys(), actual.getResultValueKeys());
573 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
574 new MetaTester().checkAfterCreate(actual.getMeta());
575
576
577 try {
578 lrcService.createResultValuesGroup(expected.getResultScaleKey(), expected.getTypeKey(), expected, callContext);
579 fail("should have gotten an already exists exception");
580 } catch (AlreadyExistsException e) {
581
582 }
583
584
585 expected = actual;
586 actual = lrcService.getResultValuesGroup(actual.getKey(), callContext);
587 assertEquals(expected.getKey(), actual.getKey());
588 new KeyEntityTester().check(expected, actual);
589 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
590 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
591 assertEquals(expected.getResultScaleKey(), actual.getResultScaleKey());
592 new ListOfStringTester().check(expected.getResultValueKeys(), actual.getResultValueKeys());
593 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
594 new MetaTester().checkAfterGet(expected.getMeta(), actual.getMeta());
595 ResultValuesGroupInfo passingGradeTranslation = actual;
596
597
598 expected = actual;
599 expected.setName("name 1 updated");
600 expected.setEffectiveDate(new Timestamp(expected.getEffectiveDate().getTime() - 2000));
601 expected.setExpirationDate(new Timestamp(expected.getExpirationDate().getTime() + 2000));
602 expected.setDescr(new RichTextHelper().fromPlain("values group 1 description updated"));
603 expected.getResultValueKeys().remove(0);
604 expected.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_F);
605 new AttributeTester().delete1Update1Add1ForUpdate(expected.getAttributes());
606 actual = lrcService.updateResultValuesGroup(expected.getKey(), expected, callContext);
607 assertEquals(expected.getKey(), actual.getKey());
608 new KeyEntityTester().check(expected, actual);
609 assertEquals(expected.getResultScaleKey(), actual.getResultScaleKey());
610 new ListOfStringTester().check(expected.getResultValueKeys(), actual.getResultValueKeys());
611 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
612 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
613 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
614 new MetaTester().checkAfterUpdate(expected.getMeta(), actual.getMeta());
615
616
617 expected = actual;
618 actual = lrcService.getResultValuesGroup(actual.getKey(), callContext);
619 assertEquals(expected.getKey(), actual.getKey());
620 new KeyEntityTester().check(expected, actual);
621 assertEquals(expected.getResultScaleKey(), actual.getResultScaleKey());
622 new ListOfStringTester().check(expected.getResultValueKeys(), actual.getResultValueKeys());
623 new TimeTester().check(expected.getEffectiveDate(), actual.getEffectiveDate());
624 new TimeTester().check(expected.getExpirationDate(), actual.getExpirationDate());
625 new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
626 new MetaTester().checkAfterGet(expected.getMeta(), actual.getMeta());
627
628
629 ResultValuesGroupInfo gradeLetter = new ResultValuesGroupInfo();
630 gradeLetter.setKey(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER);
631 gradeLetter.setTypeKey(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE);
632 gradeLetter.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
633 gradeLetter.setEffectiveDate(new Date());
634 gradeLetter.setExpirationDate(new Date(new Date().getTime() + 1000));
635 gradeLetter.setName("Letter Grades");
636 gradeLetter.setDescr(new RichTextHelper().fromPlain("Grades on an A-F letter scale"));
637 gradeLetter.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
638 gradeLetter.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_A);
639 gradeLetter.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_B);
640 gradeLetter.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_C);
641 gradeLetter.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_D);
642 gradeLetter.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_F);
643 gradeLetter = lrcService.createResultValuesGroup(gradeLetter.getResultScaleKey(), gradeLetter.getTypeKey(),
644 gradeLetter,
645 callContext);
646
647
648 ResultValuesGroupInfo gradePF = new ResultValuesGroupInfo();
649 gradePF.setKey(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL);
650 gradePF.setTypeKey(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE);
651 gradePF.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
652 gradePF.setEffectiveDate(new Date());
653 gradePF.setExpirationDate(new Date(new Date().getTime() + 1000));
654 gradePF.setName("Passing Letter Grades");
655 gradePF.setDescr(new RichTextHelper().fromPlain("Grades on the PF scale"));
656 gradePF.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_GRADE_LETTER);
657 gradePF.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_P);
658 gradePF.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_F);
659 gradePF = lrcService.createResultValuesGroup(gradePF.getResultScaleKey(), gradePF.getTypeKey(),
660 gradePF,
661 callContext);
662
663
664 ResultValuesGroupInfo creditRange1To4 = new ResultValuesGroupInfo();
665 creditRange1To4.setKey(LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_1_MINUS4);
666 creditRange1To4.setTypeKey(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE);
667 creditRange1To4.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
668 creditRange1To4.setEffectiveDate(new Date());
669 creditRange1To4.setExpirationDate(new Date(new Date().getTime() + 1000));
670 creditRange1To4.setName("1-4 credits");
671 creditRange1To4.setDescr(new RichTextHelper().fromPlain("1-4 credits"));
672 creditRange1To4.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE);
673 creditRange1To4.setResultValueRange(new ResultValueRangeInfo ());
674 creditRange1To4.getResultValueRange().setMinValue("1");
675 creditRange1To4.getResultValueRange().setMaxValue("4");
676 creditRange1To4.getResultValueRange().setIncrement("1");
677 creditRange1To4 = lrcService.createResultValuesGroup(creditRange1To4.getResultScaleKey(), creditRange1To4.getTypeKey(),
678 creditRange1To4,
679 callContext);
680
681 ResultValuesGroupInfo creditFixed2 = new ResultValuesGroupInfo();
682 creditFixed2.setKey(LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_2_0);
683 creditFixed2.setTypeKey(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED);
684 creditFixed2.setStateKey(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED);
685 creditFixed2.setEffectiveDate(new Date());
686 creditFixed2.setExpirationDate(new Date(new Date().getTime() + 1000));
687 creditFixed2.setName("2 credits");
688 creditFixed2.setDescr(new RichTextHelper().fromPlain("2 credits"));
689 creditFixed2.setResultScaleKey(LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE);
690 creditFixed2.getResultValueKeys().add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_P);
691 creditFixed2 = lrcService.createResultValuesGroup(creditFixed2.getResultScaleKey(), creditFixed2.getTypeKey(),
692 creditFixed2,
693 callContext);
694 List<String> keys = new ArrayList<String>();
695 keys.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER);
696 keys.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PASSING_TRANSLATION);
697 List<ResultValuesGroupInfo> both = lrcService.getResultValuesGroupsByKeys(keys, callContext);
698 assertEquals(keys.size(), both.size());
699 for (ResultValuesGroupInfo info : both) {
700 if (!keys.remove(info.getKey())) {
701 fail(info.getKey() + " was not in the return list");
702 }
703 }
704 assertEquals(0, keys.size());
705
706
707 keys = lrcService.getResultValuesGroupKeysByType(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE, callContext);
708 assertEquals(3, keys.size());
709 if (!keys.remove(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER)) {
710 fail("does not contain " + LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER);
711 }
712 if (!keys.remove(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PASSING_TRANSLATION)) {
713 fail("does not contain " + LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PASSING_TRANSLATION);
714 }
715 if (!keys.remove(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL)) {
716 fail("does not contain " + LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL);
717 }
718
719
720
721
722 List<String> expectedKeys = new ArrayList<String>();
723 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_A);
724 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_B);
725 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_C);
726 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_D);
727 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_F);
728 List<ResultValueInfo> rvs = lrcService.getResultValuesForResultValuesGroup(
729 LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER, callContext);
730 assertEquals(expectedKeys.size(), rvs.size());
731 for (ResultValueInfo rv : rvs) {
732 if (!expectedKeys.remove(rv.getKey())) {
733 fail(rv.getKey() + " was not expected");
734 }
735 }
736 assertEquals(0, expectedKeys.size());
737
738
739 expectedKeys = new ArrayList<String>();
740 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_A);
741 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_B);
742 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_C);
743 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_D);
744 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_LETTER_F);
745 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_P);
746 expectedKeys.add(LrcServiceConstants.RESULT_VALUE_KEY_GRADE_PF_F);
747 List<String> groupKeys = new ArrayList<String>();
748 groupKeys.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER);
749 groupKeys.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PASSING_TRANSLATION);
750 groupKeys.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL);
751
752 rvs = lrcService.getResultValuesForResultValuesGroups(groupKeys, callContext);
753 assertEquals(expectedKeys.size(), rvs.size());
754 for (ResultValueInfo rv : rvs) {
755 if (!expectedKeys.remove(rv.getKey())) {
756 fail(rv.getKey() + " was not expected");
757 }
758 }
759 assertEquals(0, expectedKeys.size());
760
761
762
763 expectedKeys.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER);
764 expectedKeys.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PASSING_TRANSLATION);
765 expectedKeys.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL);
766
767 List<ResultValuesGroupInfo> rvgs = lrcService.getResultValuesGroupsByResultScaleType(LrcServiceConstants.RESULT_SCALE_TYPE_KEY_GRADE, callContext);
768 assertEquals(expectedKeys.size(), rvgs.size());
769 for (ResultValuesGroupInfo rvg : rvgs) {
770 if (!expectedKeys.remove(rvg.getKey())) {
771 fail(rvg.getKey() + " was not expected");
772 }
773 }
774 assertEquals(0, expectedKeys.size());
775
776
777 expectedKeys.add(LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_2_0);
778 expectedKeys.add(LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_1_MINUS4);
779
780 rvgs = lrcService.getResultValuesGroupsByResultScaleType(LrcServiceConstants.RESULT_SCALE_TYPE_KEY_CREDIT, callContext);
781 assertEquals(expectedKeys.size(), rvgs.size());
782 for (ResultValuesGroupInfo rvg : rvgs) {
783 if (!expectedKeys.remove(rvg.getKey())) {
784 fail(rvg.getKey() + " was not expected");
785 }
786 }
787 assertEquals(0, expectedKeys.size());
788
789
790
791
792 StatusInfo status = lrcService.deleteResultValuesGroup(
793 LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PASSING_TRANSLATION, callContext);
794 assertNotNull(status);
795 assertTrue(status.getIsSuccess());
796 try {
797 actual = lrcService.getResultValuesGroup(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PASSING_TRANSLATION,
798 callContext);
799 fail("Did not receive DoesNotExistException when attempting to get already-deleted Entity");
800 } catch (DoesNotExistException dnee) {
801
802 }
803
804 status = lrcService.deleteResultValuesGroup(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER, callContext);
805 assertNotNull(status);
806 assertTrue(status.getIsSuccess());
807 try {
808 actual = lrcService.getResultValuesGroup(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER, callContext);
809 fail("Did not receive DoesNotExistException when attempting to get already-deleted Entity");
810 } catch (DoesNotExistException dnee) {
811
812 }
813 status = lrcService.deleteResultValuesGroup(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL, callContext);
814 assertNotNull(status);
815 assertTrue(status.getIsSuccess());
816 try {
817 actual = lrcService.getResultValuesGroup(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL, callContext);
818 fail("Did not receive DoesNotExistException when attempting to get already-deleted Entity");
819 } catch (DoesNotExistException dnee) {
820
821 }
822
823 status = lrcService.deleteResultValuesGroup(LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_2_0, callContext);
824 status = lrcService.deleteResultValuesGroup(LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_1_MINUS4, callContext);
825 }
826
827 @Test
828 public void testBusinessLogic()
829 throws DataValidationErrorException,
830 DoesNotExistException,
831 InvalidParameterException,
832 MissingParameterException,
833 OperationFailedException,
834 PermissionDeniedException,
835 ReadOnlyException,
836 VersionMismatchException,
837 AlreadyExistsException {
838
839
840 ResultValuesGroupInfo rvg = lrcService.getCreateFixedCreditResultValuesGroup("22",
841 LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, callContext);
842 assertEquals("kuali.creditType.credit.degree.22", rvg.getKey());
843 assertEquals(1, rvg.getResultValueKeys().size());
844 assertEquals("kuali.result.value.credit.degree.22", rvg.getResultValueKeys().get(0));
845 assertEquals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED, rvg.getTypeKey());
846
847 rvg = lrcService.getCreateFixedCreditResultValuesGroup("22",
848 LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, callContext);
849 assertEquals("kuali.creditType.credit.degree.22", rvg.getKey());
850 assertEquals(1, rvg.getResultValueKeys().size());
851 assertEquals("kuali.result.value.credit.degree.22", rvg.getResultValueKeys().get(0));
852 assertEquals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED, rvg.getTypeKey());
853 for (String rvKey : rvg.getResultValueKeys()) {
854 ResultValueInfo rv = this.lrcService.getResultValue(rvKey, callContext);
855 assertEquals("22", rv.getValue());
856 }
857
858 rvg = lrcService.getCreateRangeCreditResultValuesGroup("22", "24", "1",
859 LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, callContext);
860 assertEquals("kuali.creditType.credit.degree.22-24", rvg.getKey());
861 assertEquals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE, rvg.getTypeKey());
862
863 rvg = lrcService.getCreateRangeCreditResultValuesGroup("22", "24", "1",
864 LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, callContext);
865 assertEquals("kuali.creditType.credit.degree.22-24", rvg.getKey());
866 assertEquals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE, rvg.getTypeKey());
867
868
869 List<String> values = new ArrayList<String>();
870 values.add("1");
871 values.add("12");
872 values.add("16");
873 values.add("33");
874 List<String> expValueKeys = new ArrayList<String>();
875 expValueKeys.add("kuali.result.value.credit.degree.1");
876 expValueKeys.add("kuali.result.value.credit.degree.12");
877 expValueKeys.add("kuali.result.value.credit.degree.16");
878 expValueKeys.add("kuali.result.value.credit.degree.33");
879
880 rvg = lrcService.getCreateMultipleCreditResultValuesGroup(values,
881 LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, callContext);
882 assertEquals("kuali.creditType.credit.degree.1.12.16.33", rvg.getKey());
883 assertEquals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE, rvg.getTypeKey());
884 new ListOfStringTester().check(rvg.getResultValueKeys(), expValueKeys);
885 for (String rvKey : rvg.getResultValueKeys()) {
886 ResultValueInfo rv = this.lrcService.getResultValue(rvKey, callContext);
887 if (!values.contains(rv.getValue())) {
888 fail("Result value does not have an expected value");
889 }
890 }
891
892
893 rvg = lrcService.getCreateMultipleCreditResultValuesGroup(values,
894 LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, callContext);
895 assertEquals("kuali.creditType.credit.degree.1.12.16.33", rvg.getKey());
896 assertEquals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE, rvg.getTypeKey());
897 new ListOfStringTester().check(rvg.getResultValueKeys(), expValueKeys);
898 for (String rvKey : rvg.getResultValueKeys()) {
899 ResultValueInfo rv = this.lrcService.getResultValue(rvKey, callContext);
900 if (!values.contains(rv.getValue())) {
901 fail("Result value does not have an expected value");
902 }
903 }
904
905 String value = "75";
906 ResultValueInfo rv = this.lrcService.getCreateResultValueForScale(value,
907 LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, callContext);
908 assertEquals("kuali.result.value.credit.degree.75", rv.getKey());
909 assertEquals(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE, rv.getTypeKey());
910 assertEquals(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED, rv.getStateKey());
911 assertEquals(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE, rv.getTypeKey());
912 assertEquals(LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, rv.getResultScaleKey());
913 assertEquals(value, rv.getValue());
914 new FloatAsStringTester ().check(value, rv.getNumericValue());
915
916 this.lrcService.getCreateResultValueForScale(value, LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, callContext);
917 assertEquals("kuali.result.value.credit.degree.75", rv.getKey());
918 assertEquals(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE, rv.getTypeKey());
919 assertEquals(LrcServiceConstants.RESULT_VALUE_STATE_APPROVED, rv.getStateKey());
920 assertEquals(LrcServiceConstants.RESULT_VALUE_TYPE_KEY_VALUE, rv.getTypeKey());
921 assertEquals(LrcServiceConstants.RESULT_SCALE_KEY_CREDIT_DEGREE, rv.getResultScaleKey());
922 assertEquals(value, rv.getValue());
923 new FloatAsStringTester ().check(value, rv.getNumericValue());
924 }
925 }