001/** 002 * Copyright 2011-2012 The Kuali Foundation Licensed under the 003 * Educational Community License, Version 2.0 (the "License"); you may 004 * not use this file except in compliance with the License. You may 005 * obtain a copy of the License at 006 * 007 * http://www.osedu.org/licenses/ECL-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, 010 * software distributed under the License is distributed on an "AS IS" 011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing 013 * permissions and limitations under the License. 014 */ 015package org.kuali.mobility.grades.service; 016 017import java.util.Date; 018import java.util.List; 019 020import static junit.framework.Assert.*; 021 022import org.junit.Test; 023import org.junit.runner.RunWith; 024import org.kuali.mobility.grades.entity.ModuleResults; 025import org.springframework.beans.factory.annotation.Autowired; 026import org.springframework.beans.factory.annotation.Qualifier; 027import org.springframework.test.annotation.DirtiesContext; 028import org.springframework.test.context.ContextConfiguration; 029import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 030 031/** 032 * Unit test for the Grades Service 033 * @author Charl Thiem <charl@opencollab.co.za> 034 */ 035@RunWith(SpringJUnit4ClassRunner.class) 036@DirtiesContext 037@ContextConfiguration("classpath:/GradesSpringBeans.xml") 038public class GradesServiceImplTest { 039 040 /** 041 * A reference to the <code>GradesService</code> 042 */ 043 @Autowired 044 @Qualifier("gradesService") 045 private GradesService gradesService; 046 047 /** 048 * This test will call the service and retrieve a pre-configured set of results. 049 * This test will simply check that the data is in the order we expected, and also 050 * provide a sanity check that the services still properly call the DAO, 051 */ 052 @Test 053 public void test() { 054 List<ModuleResults> results = gradesService.getResults(new Date(), new Date(), "test", "en"); 055 String str; 056 057 // Check that we have the expected first mark 058 str = results.get(0).getExamMark(); 059 assertEquals("76%", str); 060 061 // Check the participationMarkComment of the second result 062 str = results.get(1).getParticipationMarkComment(); 063 assertEquals("Distinction", str); 064 065 // Check the module code of the third result 066 str = results.get(2).getModuleName(); 067 assertEquals("IOPS 1 21 INTRO HUM GEO", str); 068 069 } 070}