View Javadoc

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