View Javadoc
1   /*
2    * Copyright 2006-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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  
17  package org.kuali.rice.kew.rule.service.impl;
18  
19  import org.junit.Test;
20  import org.kuali.rice.kew.rule.RuleDelegationBo;
21  import org.kuali.rice.kew.service.KEWServiceLocator;
22  import org.kuali.rice.kew.test.KEWTestCase;
23  import org.kuali.rice.test.BaselineTestCase;
24  
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  import static org.junit.Assert.assertNotNull;
29  import static org.junit.Assert.assertNull;
30  import static org.junit.Assert.assertTrue;
31  
32  @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
33  public class DelegationRuleServiceTest extends KEWTestCase {
34  
35  
36      @Test
37      public void testRetrievalOfDelegationRules() throws Exception {
38          loadXmlFile("org/kuali/rice/kew/rule/RouteTemplateConfig.xml");
39          loadXmlFile("org/kuali/rice/kew/rule/RulesWithoutResponsibilities.xml");
40          //Loading Delegation rule test data. The xml file contains two delegation rules
41          loadXmlFile("org/kuali/rice/kew/rule/DelegationRules.xml");
42          List<RuleDelegationBo> delegationRuleList;
43  
44          //There are two delegations rules, both need to be returned
45          delegationRuleList = KEWServiceLocator.getRuleDelegationService().search(null, null, null, null, null, null, null, null, null,Boolean.TRUE ,null,null);
46          assertNotNull("The returned delegation rule list should not be null", delegationRuleList);
47  
48          //Only one delegation rule is of document type RiceDocument.child1
49          delegationRuleList = KEWServiceLocator.getRuleDelegationService().search(null,null,"RiceDocument.child1",null,null,null,null,null,null,Boolean.TRUE,null,null);
50          assertTrue(delegationRuleList.size() == 1);
51  
52          //Only one delegation rule has description "A rule with a group responsibility"
53          delegationRuleList = KEWServiceLocator.getRuleDelegationService().search(null,null,null,null,null,"A rule with a group responsibility",null,null,null,Boolean.TRUE,null,null);
54          assertTrue(delegationRuleList.size() == 1);
55  
56          //Setting Active indicator to false, should not return any values as both the delegation rules are active
57          delegationRuleList = KEWServiceLocator.getRuleDelegationService().search(null,null,null,null,null,null,null,null,null,Boolean.FALSE,null,null);
58          assertTrue(delegationRuleList.isEmpty());
59  }
60  
61  }