View Javadoc

1   /**
2    * Copyright 2011-2012 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  package org.kuali.mobility.grades.service;
16  
17  import java.util.Date;
18  import java.util.List;
19  
20  import static junit.framework.Assert.*;
21  
22  import org.junit.Test;
23  import org.junit.runner.RunWith;
24  import org.kuali.mobility.grades.entity.ModuleResults;
25  import org.springframework.beans.factory.annotation.Autowired;
26  import org.springframework.beans.factory.annotation.Qualifier;
27  import org.springframework.test.annotation.DirtiesContext;
28  import org.springframework.test.context.ContextConfiguration;
29  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
30  
31  /**
32   * Unit test for the Grades Service
33   * @author Charl Thiem <charl@opencollab.co.za>
34   */
35  @RunWith(SpringJUnit4ClassRunner.class)
36  @DirtiesContext
37  @ContextConfiguration("classpath:/GradesSpringBeans.xml")
38  public class GradesServiceImplTest {
39  	
40  	/**
41  	 * A reference to the <code>GradesService</code>
42  	 */
43  	@Autowired
44  	@Qualifier("gradesService")
45  	private GradesService gradesService;
46  
47  	/**
48  	 * This test will call the service and retrieve a pre-configured set of results.
49  	 * This test will simply check that the data is in the order we expected, and also 
50  	 * provide a sanity check that the services still properly call the DAO,
51  	 */
52  	@Test
53  	public void test() {
54  		List<ModuleResults> results = gradesService.getResults(new Date(), new Date(), "test", "en");
55  		String str;
56  		
57  		// Check that we have the expected first mark
58  		str = results.get(0).getExamMark();
59  		assertEquals("76%", str);
60  		
61  		// Check the participationMarkComment of the second result
62  		str = results.get(1).getParticipationMarkComment();
63  		assertEquals("Distinction", str);
64  		
65  		// Check the module code of the third result
66  		str = results.get(2).getModuleName();
67  		assertEquals("IOPS 1 21 INTRO HUM GEO", str);
68  		
69  	}
70  }