View Javadoc

1   /**
2    * Copyright 2005-2012 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  package org.kuali.rice.krms.impl.repository;
17  
18  import org.junit.Before;
19  import org.junit.Test;
20  import org.kuali.rice.core.api.criteria.PredicateFactory;
21  import org.kuali.rice.core.api.criteria.QueryByCriteria;
22  import org.kuali.rice.krad.criteria.CriteriaLookupDaoProxy;
23  import org.kuali.rice.krad.criteria.CriteriaLookupServiceImpl;
24  import org.kuali.rice.krms.api.repository.reference.ReferenceObjectBinding;
25  import org.kuali.rice.krms.test.AbstractBoTest;
26  
27  /**
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   *
30   */
31  public final class ReferenceObjectBindingIntegrationGenTest extends AbstractBoTest {
32  
33  
34      ReferenceObjectBindingBoServiceImpl referenceObjectBindingBoServiceImpl;
35      ReferenceObjectBinding referenceObjectBinding;
36  
37      ReferenceObjectBinding getReferenceObjectBinding() {
38          return referenceObjectBinding;
39      }
40  
41      /**
42       * Note lower case u, do not override superclasses setUp
43       *
44       */
45      @Before
46      public void setup() {
47          referenceObjectBindingBoServiceImpl = new ReferenceObjectBindingBoServiceImpl();
48          referenceObjectBindingBoServiceImpl.setBusinessObjectService(getBoService());
49      }
50  
51      @Test(expected = java.lang.IllegalArgumentException.class)
52      public void test_findReferenceObjectBindingsByCollectionName_null_fail() {
53          (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByCollectionName_null_fail();
54      }
55  
56      @Test(expected = java.lang.IllegalArgumentException.class)
57      public void test_findReferenceObjectBindingsByKrmsDiscriminatorType_null_fail() {
58          (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByKrmsDiscriminatorType_null_fail();
59      }
60  
61      @Test(expected = java.lang.IllegalArgumentException.class)
62      public void test_findReferenceObjectBindingsByKrmsObject_null_fail() {
63          (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByKrmsObject_null_fail();
64      }
65  
66      @Test(expected = java.lang.IllegalArgumentException.class)
67      public void test_findReferenceObjectBindingsByNamespace_null_fail() {
68          (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByNamespace_null_fail();
69      }
70  
71      @Test(expected = java.lang.IllegalArgumentException.class)
72      public void test_findReferenceObjectBindingsByReferenceDiscriminatorType_null_fail() {
73          (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByReferenceDiscriminatorType_null_fail();
74      }
75  
76      @Test(expected = java.lang.IllegalArgumentException.class)
77      public void test_findReferenceObjectBindingsByReferenceObject_null_fail() {
78          (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByReferenceObject_null_fail();
79      }
80  
81      @Test
82      public void test_from_null_yields_null() {
83          (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_from_null_yields_null();
84      }
85  
86      @Test
87      public void test_to() {
88          (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_to();
89      }
90  
91      @Test
92      public void test_createReferenceObjectBinding() {
93          ReferenceObjectBindingBoServiceImplGenTest test = ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl);
94          test.test_createReferenceObjectBinding();
95          referenceObjectBinding = test.getReferenceObjectBinding();
96          assert(referenceObjectBinding != null);
97          assert(referenceObjectBinding.getId() != null);
98      }
99  
100     @Test(expected = java.lang.IllegalStateException.class)
101     public void test_createReferenceObjectBinding_fail_existing() {
102         test_createReferenceObjectBinding();
103         test_createReferenceObjectBinding();
104     }
105 
106     @Test(expected = java.lang.IllegalArgumentException.class)
107     public void test_createReferenceObjectBinding_null_fail() {
108         (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_createReferenceObjectBinding_null_fail();
109     }
110 
111     @Test
112     public void test_getReferenceObjectBinding() {
113         test_createReferenceObjectBinding();
114         ReferenceObjectBinding def = getReferenceObjectBinding();
115         ReferenceObjectBinding def2 = referenceObjectBindingBoServiceImpl.getReferenceObjectBinding(def.getId());
116         assert(def2 != null);
117         assert(def2.equals(def));
118     }
119 
120     @Test
121     public void test_updateReferenceObjectBinding() {
122         test_createReferenceObjectBinding();
123         ReferenceObjectBinding def = getReferenceObjectBinding();
124         String id = def.getId();
125         assert(!"UpdateTest".equals(def.getCollectionName()));
126         ReferenceObjectBindingBo bo = referenceObjectBindingBoServiceImpl.from(def);
127         bo.setCollectionName("UpdateTest");
128         referenceObjectBindingBoServiceImpl.updateReferenceObjectBinding(ReferenceObjectBinding.Builder.create(bo).build());
129         ReferenceObjectBinding def2 = referenceObjectBindingBoServiceImpl.getReferenceObjectBinding(id);
130         assert("UpdateTest".equals(def2.getCollectionName()));
131     }
132 
133     @Test(expected = java.lang.IllegalArgumentException.class)
134     public void test_updateReferenceObjectBinding_null_fail() {
135         (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_updateReferenceObjectBinding_null_fail();
136     }
137 
138     @Test
139     public void test_deleteReferenceObjectBinding() {
140         test_createReferenceObjectBinding();
141         ReferenceObjectBinding def = getReferenceObjectBinding();
142         String id = def.getId();
143         referenceObjectBindingBoServiceImpl.deleteReferenceObjectBinding(id);
144         ReferenceObjectBinding def2 = referenceObjectBindingBoServiceImpl.getReferenceObjectBinding(id);
145         assert(def2 == null);
146     }
147 
148     @Test(expected = java.lang.IllegalArgumentException.class)
149     public void test_deleteReferenceObjectBinding_null_fail() {
150         (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_deleteReferenceObjectBinding_null_fail();
151     }
152 
153     @Test
154     public void test_Find() {
155         QueryByCriteria.Builder query = QueryByCriteria.Builder.create();
156         query.setPredicates(PredicateFactory.equal("id", "ID"));
157         CriteriaLookupServiceImpl criteria = new CriteriaLookupServiceImpl();
158         criteria.setCriteriaLookupDao(new CriteriaLookupDaoProxy());
159         referenceObjectBindingBoServiceImpl.setCriteriaLookupService(criteria);
160         assert(referenceObjectBindingBoServiceImpl.findReferenceObjectBindingIds(query.build()).isEmpty());
161         test_createReferenceObjectBinding();
162         assert(!referenceObjectBindingBoServiceImpl.findReferenceObjectBindingIds(query.build()).isEmpty());
163         assert("ID".equals(referenceObjectBindingBoServiceImpl.findReferenceObjectBindingIds(query.build()).get(0)));
164     }
165 }