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.lrc.dao.impl;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNotNull;
20  import static org.junit.Assert.assertTrue;
21  
22  import java.util.List;
23  
24  import org.junit.Test;
25  import org.kuali.student.common.exceptions.DoesNotExistException;
26  import org.kuali.student.common.test.spring.AbstractTransactionalDaoTest;
27  import org.kuali.student.common.test.spring.Dao;
28  import org.kuali.student.common.test.spring.PersistenceFileLocation;
29  import org.kuali.student.lum.lrc.dao.LrcDao;
30  import org.kuali.student.lum.lrc.entity.ResultComponentType;
31  
32  @PersistenceFileLocation("classpath:META-INF/lrc-persistence.xml")
33  public class TestLrcDaoImpl extends AbstractTransactionalDaoTest {
34  	@Dao(value = "org.kuali.student.lum.lrc.dao.impl.LrcDaoImpl", testSqlFile = "classpath:ks-lrc.sql")
35  	public LrcDao dao;
36  
37  	@Test
38      public void testGetResultComponentIdsByResult() {
39          List<String> rcis = dao.getResultComponentIdsByResult("LRC-RESULT_VALUE-CREDIT-1", "resultComponentType.credential");
40          assertNotNull(rcis);
41          assertEquals(1, rcis.size());
42  
43          rcis = dao.getResultComponentIdsByResult("LRC-RESULT_VALUE-CREDIT-1x", "resultComponentType.credential");
44          assertTrue(rcis.isEmpty());
45  
46          rcis = dao.getResultComponentIdsByResult("LRC-RESULT_VALUE-CREDIT-1", "resultComponentType.credentialx");
47          assertTrue(rcis.isEmpty());
48      }
49  
50      @Test
51      public void testGetResultComponentIdsByResultComponentType() {
52          List<String> rcis = dao.getResultComponentIdsByResultComponentType("resultComponentType.credential");
53          assertNotNull(rcis);
54          assertEquals(1, rcis.size());
55  
56          rcis = dao.getResultComponentIdsByResultComponentType("resultComponentType.credentialx");
57          assertTrue(rcis.isEmpty());
58      }
59  
60      @Test
61      public void testGetResultComponentType() {
62          try {
63              @SuppressWarnings("unused")
64              ResultComponentType rcti = dao.getResultComponentType("resultComponentType.credential");
65              assertTrue(true);
66          } catch (DoesNotExistException e) {
67              assertTrue(false);
68          }
69  
70          try {
71              @SuppressWarnings("unused")
72              ResultComponentType rcti = dao.getResultComponentType("resultComponentType.credentialYYY");
73              assertTrue(false);
74          } catch (DoesNotExistException e) {
75              assertTrue(true);
76          }
77  
78      }
79  }