Clover Coverage Report - kns-test 2.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
15   66   3   5
0   34   0.2   3
3     1  
1    
 
  ReportQueryByCriteriaTest       Line # 32 15 0% 3 18 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.kuali.rice.kns.jpa;
17   
18    import org.apache.commons.lang.StringUtils;
19    import org.junit.Test;
20    import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria;
21    import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria.QueryByCriteriaType;
22    import org.kuali.rice.kns.test.document.bo.Account;
23    import org.kuali.test.KNSTestCase;
24   
25    import static org.junit.Assert.assertTrue;
26   
27    /**
28    * Junit test cases for org.kuali.rice.core.jpa.criteria.ReportQueryByCriteria
29    *
30    * @author Kuali Rice Team (rice.collab@kuali.org)
31    */
 
32    public class ReportQueryByCriteriaTest extends KNSTestCase {
33   
 
34  0 toggle @Test
35    public void testCriteriaToReportQuery_emptySelect() throws Exception {
36  0 Criteria criteria = new Criteria(Account.class.getName(), "a");
37   
38  0 String query = criteria.toQuery(QueryByCriteriaType.SELECT, new String[0]);
39  0 assertTrue(StringUtils.equalsIgnoreCase(query, "select a from org.kuali.rice.kns.test.document.bo.Account as a"));
40    }
41   
 
42  0 toggle @Test
43    public void testCriteriaToReportQuery_singleFieldSelect() throws Exception {
44  0 Criteria criteria = new Criteria(Account.class.getName(), "a");
45   
46  0 String[] attr = new String[1];
47  0 attr[0] = "number";
48   
49  0 String query = criteria.toQuery(QueryByCriteriaType.SELECT, attr);
50  0 assertTrue(StringUtils.equalsIgnoreCase(query, "select a.number from org.kuali.rice.kns.test.document.bo.Account as a"));
51    }
52   
 
53  0 toggle @Test
54    public void testCriteriaToReportQuery_multipleFieldSelect() throws Exception {
55  0 Criteria criteria = new Criteria(Account.class.getName(), "a");
56   
57  0 String[] attr = new String[3];
58  0 attr[0] = "number";
59  0 attr[1] = "name";
60  0 attr[2] = "amId";
61   
62  0 String query = criteria.toQuery(QueryByCriteriaType.SELECT, attr);
63  0 assertTrue(StringUtils.equalsIgnoreCase(query, "select a.number, a.name, a.amId from org.kuali.rice.kns.test.document.bo.Account as a"));
64    }
65   
66    }