View Javadoc

1   /**
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.krms.termresolver;
17  
18  import org.junit.Before;
19  import org.junit.Ignore;
20  import org.junit.Test;
21  import org.junit.runner.RunWith;
22  import org.kuali.rice.krms.impl.type.KrmsTypeResolver;
23  import org.kuali.student.common.util.krms.RulesExecutionConstants;
24  import org.kuali.student.enrollment.academicrecord.dto.GPAInfo;
25  import org.kuali.student.enrollment.academicrecord.service.AcademicRecordService;
26  import org.kuali.student.krms.util.KSKRMSExecutionConstants;
27  import org.kuali.student.krms.util.KSKRMSExecutionUtil;
28  import org.kuali.student.r2.common.dto.ContextInfo;
29  import org.kuali.student.r2.common.dto.LocaleInfo;
30  import org.springframework.test.context.ContextConfiguration;
31  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
32  
33  import javax.annotation.Resource;
34  import java.util.HashMap;
35  import java.util.Map;
36  
37  import static org.junit.Assert.assertEquals;
38  import static org.junit.Assert.assertNotNull;
39  
40  @RunWith(SpringJUnit4ClassRunner.class)
41  @ContextConfiguration(locations = {"classpath:ks-krms-test-context-mock.xml"})
42  @Ignore
43  public class TestGPATermResolver {
44          private KrmsTypeResolver typeResolver;
45          private String studentID = "12020303";
46          private String CalcTypeID = "mockTypeKey3";
47  
48          public ContextInfo callContext = null;
49          @Resource(name = "acadRecordService")
50          private AcademicRecordService academicRecordService;
51  
52          @Before
53          public void setUp() {
54              callContext = new ContextInfo();
55          }
56  
57  
58          @Test
59          public void testAcadRecordServiceNotNull() {
60              assertNotNull(academicRecordService);
61          }
62  
63          @Test
64          public void testResolve() {
65  
66              GPATermResolver termResolver = new GPATermResolver();
67              termResolver.setAcademicRecordService(academicRecordService);
68              Map<String, Object> resolvedPrereqs = new HashMap<String, Object>();
69              Map<String, String> parameters = new HashMap<String, String>();
70  
71              ContextInfo context = new ContextInfo();
72              context.setLocale(new LocaleInfo());
73              context.setPrincipalId("nina");
74  
75              resolvedPrereqs.put(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME, context);
76              parameters.put(KSKRMSExecutionConstants.PERSON_ID_TERM_PROPERTY, studentID);
77              parameters.put(KSKRMSExecutionConstants.CALC_TYPE_KEY_TERM_PROPERTY, CalcTypeID) ;
78  
79              GPAInfo result = null;
80              result = termResolver.resolve(resolvedPrereqs, parameters) ;
81              // TODO Do some assert statements on the expected returned list.
82              assertNotNull(result);
83              assertEquals(result.getCalculationTypeKey(), CalcTypeID );
84              assertEquals(result.getScaleKey(), "1" );
85              assertEquals(result.getValue(), "3.9" );
86  
87  
88          }
89  
90  
91  
92      }