View Javadoc

1   /**
2    * Copyright 2010 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.lum.statement.service.impl;
17  
18  import static org.junit.Assert.assertEquals;
19  
20  import org.junit.BeforeClass;
21  import org.junit.Ignore;
22  import org.junit.Test;
23  import org.junit.runner.RunWith;
24  import org.kuali.student.r2.common.exceptions.DoesNotExistException;
25  import org.kuali.student.r2.common.exceptions.InvalidParameterException;
26  import org.kuali.student.r2.common.exceptions.MissingParameterException;
27  import org.kuali.student.r2.common.exceptions.OperationFailedException;
28  import org.kuali.student.r1.core.statement.service.StatementService;
29  import org.springframework.beans.factory.annotation.Autowired;
30  import org.springframework.test.context.ContextConfiguration;
31  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
32  
33  @RunWith(SpringJUnit4ClassRunner.class)
34  @ContextConfiguration(locations={"classpath:statement-additional-context.xml"})
35  public class TestStatementServiceImplForCourse {
36  
37  	@Autowired
38      public StatementService statementService;
39  
40  	@BeforeClass
41  	public static void beforeClass() {
42  	}
43  
44  //    @Test
45  //    public void hello()
46  //    {
47  //
48  //    }
49  
50      @Test
51      public void testGetNaturalLanguageForReqComponent_DefaultEnglish() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
52          //req. type: 'kuali.reqComponent.type.course.courseset.completed.none'
53          String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-1", "KUALI.RULE", null);
54          assertEquals("Must not have successfully completed MATH152", nl);
55      }
56  
57      @Test
58      public void testGetNaturalLanguageForReqComponent_none1() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
59          //req. type: 'kuali.reqComponent.type.course.courseset.completed.none'
60          String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-1", "KUALI.RULE", "en");
61          assertEquals("Must not have successfully completed MATH152", nl);
62      }
63  
64      @Test
65      public void testGetNaturalLanguageForReqComponent_noneN() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
66          //req. type: 'kuali.reqComponent.type.course.courseset.completed.none'
67          String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-2", "KUALI.RULE", "en");
68          assertEquals("Must not have successfully completed any courses from (MATH152, MATH180)", nl);
69      }
70  
71      @Test
72      public void testGetNaturalLanguageForReqComponent_all1() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
73          //req. type: 'kuali.reqComponent.type.course.courseset.completed.all'
74          String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-3", "KUALI.RULE", "en");
75          assertEquals("Must have successfully completed MATH152", nl);
76      }
77  
78      @Test
79      public void testGetNaturalLanguageForReqComponent_allN() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
80          //req. type: 'kuali.reqComponent.type.course.courseset.completed.all'
81          String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-4", "KUALI.RULE", "en");
82          assertEquals("Must have successfully completed all courses from (MATH152, MATH180)", nl);
83      }
84  
85      @Test
86      public void testGetNaturalLanguageForReqComponent_1of1() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
87          //req. type: 'kuali.reqComponent.type.course.courseset.completed.nof '
88          String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-5", "KUALI.RULE", "en");
89          assertEquals("Must have successfully completed MATH152", nl);
90      }
91  
92  	@Test
93  	public void testGetNaturalLanguageForReqComponent_1ofN() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
94  	    //req. type: 'kuali.reqComponent.type.course.courseset.completed.nof '
95  		String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-6", "KUALI.RULE", "en");
96      	assertEquals("Must have successfully completed a minimum of 1 course from (MATH152, MATH180)", nl);
97  	}
98  
99      @Test
100     public void testGetNaturalLanguageForReqComponent_2ofN() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
101         //req. type: 'kuali.reqComponent.type.course.courseset.completed.nof '
102         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-7", "KUALI.RULE", "en");
103         assertEquals("Must have successfully completed a minimum of 2 courses from (MATH152, MATH180)", nl);
104     }
105 
106     @Test
107     public void testGetNaturalLanguageForReqComponent_enroll_1ofN() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
108         //req. type: 'kuali.reqComponent.type.course.courseset.enrolled.nof'
109         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-8", "KUALI.RULE", "en");
110         assertEquals("Must be concurrently enrolled in a minimum of 1 course from (MATH152, MATH180)", nl);
111     }
112 
113     @Test
114     public void testGetNaturalLanguageForReqComponent_enroll_2ofN() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
115         //req. type: 'kuali.reqComponent.type.course.courseset.enrolled.nof'
116         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-9", "KUALI.RULE", "en");
117         assertEquals("Must be concurrently enrolled in a minimum of 2 courses from (MATH152, MATH180)", nl);
118     }
119 
120     @Test
121     public void testGetNaturalLanguageForReqComponent_credits_1ofN() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
122         //req. type: 'kuali.reqComponent.type.course.courseset.credits.completed.nof'
123         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-10", "KUALI.RULE", "en");
124         assertEquals("Must have successfully completed a minimum of 1 credit from (MATH152, MATH180)", nl);
125     }
126 
127     @Test
128     public void testGetNaturalLanguageForReqComponent_credits_2ofN() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
129         //req. type: 'kuali.reqComponent.type.course.courseset.credits.completed.nof'
130         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-11", "KUALI.RULE", "en");
131         assertEquals("Must have successfully completed a minimum of 2 credits from (MATH152, MATH180)", nl);
132     }
133 
134     @Test
135     public void testGetNaturalLanguageForReqComponent_credits_none() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
136         //req. type: 'kuali.reqComponent.type.course.courseset.credits.completed.none'
137         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-12", "KUALI.RULE", "en");
138         assertEquals("Must not have successfully completed any credits from (MATH152, MATH180)", nl);
139     }
140 
141     @Test
142     public void testGetNaturalLanguageForReqComponent_credits_max1() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
143         //req. type: 'kuali.reqComponent.type.course.courseset.credits.completed.max'
144         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-13", "KUALI.RULE", "en");
145         assertEquals("Must successfully complete no more than 1 credit from (MATH152, MATH180)", nl);
146     }
147 
148     @Test
149     public void testGetNaturalLanguageForReqComponent_credits_max2() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
150         //req. type: 'kuali.reqComponent.type.course.courseset.credits.completed.max'
151         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-14", "KUALI.RULE", "en");
152         assertEquals("Must successfully complete no more than 2 credits from (MATH152, MATH180)", nl);
153     }
154 
155     @Test
156     public void testGetNaturalLanguageForReqComponent_gradecheck() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
157         //req. type: 'kuali.reqComponent.type.course.courseset.gpa.min'
158         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-15", "KUALI.RULE", "en");
159         assertEquals("Must have earned a minimum GPA of 3.5 in (MATH152, MATH180)", nl);
160     }
161 
162     @Test
163     public void testGetNaturalLanguageForReqComponent_grade_min_GradeType_Letter() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
164         //req. type: 'kuali.reqComponent.type.course.courseset.grade.min'
165         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-16a", "KUALI.RULE", "en");
166         assertEquals("Must have earned a minimum grade of letter B in (MATH152, MATH180)", nl);
167     }
168 
169     @Test
170     public void testGetNaturalLanguageForReqComponent_grade_min_GradeType_Percentage() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
171         //req. type: 'kuali.reqComponent.type.course.courseset.grade.min'
172         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-16b", "KUALI.RULE", "en");
173         assertEquals("Must have earned a minimum grade of percentage 70-79% in (MATH152, MATH180)", nl);
174     }
175 
176     @Test
177     public void testGetNaturalLanguageForReqComponent_grade_min_GradeType_PassFail() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
178         //req. type: 'kuali.reqComponent.type.course.courseset.grade.min'
179         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-16c", "KUALI.RULE", "en");
180         assertEquals("Must have earned a minimum grade of Pass in (MATH152, MATH180)", nl);
181     }
182 
183     @Test
184     public void testGetNaturalLanguageForReqComponent_grade_min_GradeType_CompletedNotation() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
185         //req. type: 'kuali.reqComponent.type.course.courseset.grade.min'
186         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-16d", "KUALI.RULE", "en");
187         assertEquals("Must have earned a minimum grade of In-Progress in (MATH152, MATH180)", nl);
188     }
189 
190     @Test
191     public void testGetNaturalLanguageForReqComponent_grade_min_GradeType_Satisfactory() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
192         //req. type: 'kuali.reqComponent.type.course.courseset.grade.min'
193         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-16e", "KUALI.RULE", "en");
194         assertEquals("Must have earned a minimum grade of Satisfactory in (MATH152, MATH180)", nl);
195     }
196 
197     @Test
198     public void testGetNaturalLanguageForReqComponent_grade_max_GradeType_Letter() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
199         //req. type: 'kuali.reqComponent.type.course.courseset.grade.max'
200         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-17a", "KUALI.RULE", "en");
201         assertEquals("Must not have earned a maximum grade of letter C or higher in (MATH152, MATH180)", nl);
202     }
203 
204     @Test
205     public void testGetNaturalLanguageForReqComponent_grade_max_GradeType_CompletedNotation() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
206         //req. type: 'kuali.reqComponent.type.course.courseset.grade.max'
207         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-17b", "KUALI.RULE", "en");
208         assertEquals("Must not have earned a maximum grade of Not-Satisfactory or higher in (MATH152, MATH180)", nl);
209     }
210 
211     @Test
212     public void testGetNaturalLanguageForReqComponent_perm_org() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
213         //req. type: 'kuali.reqComponent.type.course.permission.org.required'
214         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-18", "KUALI.RULE", "en");
215         assertEquals("Permission of English Dept required", nl);
216     }
217 
218     @Test
219     public void testGetNaturalLanguageForReqComponent_perm_instructor() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
220         //req. type: 'kuali.reqComponent.type.course.permission.instructor.required'
221         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-19", "KUALI.RULE", "en");
222         assertEquals("Permission of instructor required", nl);
223     }
224 
225     @Test
226     public void testGetNaturalLanguageForReqComponent_allN_CluSetOfClusets() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
227         //req. type: 'kuali.reqComponent.type.course.courseset.completed.all'
228         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-20", "KUALI.RULE", "en");
229         assertEquals("Must have successfully completed all courses from (MATH152, MATH221, MATH180, MATH200, MATH215)", nl);
230     }
231 
232     @Test
233     public void testGetNaturalLanguageForReqComponent_MinTestScoreOnTest() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
234         //req. type: 'kuali.reqComponent.type.course.test.score.min'
235         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-21", "KUALI.RULE", "en");
236         assertEquals("Must have achieved a minimum score of 600 on SAT Critical Reading Exam", nl);
237     }
238 
239     @Test
240     public void testGetNaturalLanguageForReqComponent_MaxTestScoreOnTest() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
241         //req. type: 'kuali.reqComponent.type.course.test.score.max'
242         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-22", "KUALI.RULE", "en");
243         assertEquals("Must have achieved a score no higher than 900 on SAT Critical Reading Exam", nl);
244     }
245 
246     @Test
247     public void testGetNaturalLanguageForReqComponent_MinCoursesMinGradeTest_GradeType_Letter() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
248         //req. type: 'kuali.reqComponent.type.course.courseset.nof.grade.min'
249         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-23a", "KUALI.RULE", "en");
250         assertEquals("Must successfully complete a minimum of 1 course with a minimum grade of letter B from (MATH152, MATH180)", nl);
251     }
252 
253     @Test
254     public void testGetNaturalLanguageForReqComponent_MinCoursesMinGradeTest_GradeType_CompletedNotation() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
255         //req. type: 'kuali.reqComponent.type.course.courseset.nof.grade.min'
256         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-23b", "KUALI.RULE", "en");
257         assertEquals("Must successfully complete a minimum of 1 course with a minimum grade of Completed from (MATH152, MATH180)", nl);
258     }
259 
260     @Test
261     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_org_duration_ProgramAsClu() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
262         //req. type: 'kuali.reqComponent.type.course.program.admitted.org.duration'
263         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-24a", "KUALI.RULE", "en");
264         assertEquals("Students admitted to Sociology may take no more than 2 courses in the English Dept in 1 year", nl);
265     }
266 
267     @Test
268     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_org_duration_ProgramAsCluSet() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
269         //req. type: 'kuali.reqComponent.type.course.program.admitted.org.duration'
270         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-24b", "KUALI.RULE", "en");
271         assertEquals("Students admitted to Sociology may take no more than 2 courses in the English Dept in 1 year", nl);
272     }
273 
274     @Test
275     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_org_duration_ProgramAsClu() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
276         //req. type: 'kuali.reqComponent.type.course.program.notadmitted.org.duration'
277         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-25a", "KUALI.RULE", "en");
278         assertEquals("Students not admitted to Sociology may take no more than 3 courses in the Computer Science Dept in 1 year", nl);
279     }
280 
281     @Test
282     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_org_duration_ProgramAsCluSet() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
283         //req. type: 'kuali.reqComponent.type.course.program.notadmitted.org.duration'
284         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-25b", "KUALI.RULE", "en");
285         assertEquals("Students not admitted to Sociology may take no more than 3 courses in the Computer Science Dept in 1 year", nl);
286     }
287 
288     @Test
289     public void testGetNaturalLanguageForReqComponent_kuali_reqComponent_type_course_org_program_admitted() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
290         //req. type: 'kuali.reqComponent.type.course.org.program.admitted'
291         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-26", "KUALI.RULE", "en");
292         assertEquals("Must be admitted to any program offered at the course campus location", nl);
293     }
294 
295     @Test
296     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_ProgramAsClu() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
297         //req. type: 'kuali.reqComponent.type.course.program.notadmitted'
298         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-27a", "KUALI.RULE", "en");
299         assertEquals("Must not have been admitted to the Sociology program", nl);
300     }
301 
302     @Test
303     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_ProgramAsCluSet() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
304         //req. type: 'kuali.reqComponent.type.course.program.notadmitted'
305         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-27b", "KUALI.RULE", "en");
306         assertEquals("Must not have been admitted to the Sociology program", nl);
307     }
308 
309     @Test
310     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_credits_repeat_max() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
311         //req. type: 'kuali.reqComponent.type.course.credits.repeat.max'
312         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-28", "KUALI.RULE", "en");
313         assertEquals("May be repeated for a maximum of 6 credits", nl);
314     }
315 
316     @Test
317     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_org_credits_completed_min() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
318         //req. type: 'kuali.reqComponent.type.course.org.credits.completed.min'
319         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-29", "KUALI.RULE", "en");
320         assertEquals("Must have successfully completed a minimum of 30 credits from courses in the Computer Science Dept", nl);
321     }
322 
323     @Test
324     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_ProgramAsClu() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
325         //req. type: 'kuali.reqComponent.type.course.program.admitted'
326         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-30a", "KUALI.RULE", "en");
327         assertEquals("Must have been admitted to the Sociology program", nl);
328     }
329 
330     @Test
331     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_ProgramAsCluSet() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
332         //req. type: 'kuali.reqComponent.type.course.program.admitted'
333         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-30b", "KUALI.RULE", "en");
334         assertEquals("Must have been admitted to the Sociology program", nl);
335     }
336 
337     @Test
338     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_completed() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
339         //req. type: 'kuali.reqComponent.type.course.completed'
340         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-31", "KUALI.RULE", "en");
341         assertEquals("Must have successfully completed MATH152", nl);
342     }
343 
344     @Test
345     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_enrolled() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
346         //req. type: 'kuali.reqComponent.type.course.enrolled'
347         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-32", "KUALI.RULE", "en");
348         assertEquals("Must be concurrently enrolled in MATH152", nl);
349     }
350 
351     @Test
352     public void testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_notcompleted() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
353         //req. type: 'kuali.reqComponent.type.course.notcompleted'
354         String nl = statementService.getNaturalLanguageForReqComponent("REQCOMP-33", "KUALI.RULE", "en");
355         assertEquals("Must not have successfully completed MATH152", nl);
356     }
357 }