1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
29
30
31 public final class ReferenceObjectBindingIntegrationGenTest extends AbstractBoTest {
32 ReferenceObjectBindingBoServiceImpl referenceObjectBindingBoServiceImpl;
33 ReferenceObjectBinding referenceObjectBinding;
34
35
36
37
38
39 @Before
40 public void setup() {
41 referenceObjectBindingBoServiceImpl = new ReferenceObjectBindingBoServiceImpl();
42 referenceObjectBindingBoServiceImpl.setDataObjectService(getDataObjectService());
43 }
44
45 @Test(expected = IllegalArgumentException.class)
46 public void test_findReferenceObjectBindingsByCollectionName_null_fail() {
47 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByCollectionName_null_fail();
48 }
49
50 @Test(expected = IllegalArgumentException.class)
51 public void test_findReferenceObjectBindingsByKrmsDiscriminatorType_null_fail() {
52 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByKrmsDiscriminatorType_null_fail();
53 }
54
55 @Test(expected = IllegalArgumentException.class)
56 public void test_findReferenceObjectBindingsByKrmsObject_null_fail() {
57 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByKrmsObject_null_fail();
58 }
59
60 @Test(expected = IllegalArgumentException.class)
61 public void test_findReferenceObjectBindingsByNamespace_null_fail() {
62 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByNamespace_null_fail();
63 }
64
65 @Test(expected = IllegalArgumentException.class)
66 public void test_findReferenceObjectBindingsByReferenceDiscriminatorType_null_fail() {
67 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByReferenceDiscriminatorType_null_fail();
68 }
69
70 @Test(expected = IllegalArgumentException.class)
71 public void test_findReferenceObjectBindingsByReferenceObject_null_fail() {
72 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_findReferenceObjectBindingsByReferenceObject_null_fail();
73 }
74
75 @Test
76 public void test_from_null_yields_null() {
77 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_from_null_yields_null();
78 }
79
80 @Test
81 public void test_to() {
82 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_to();
83 }
84
85 @Test
86 public void test_createReferenceObjectBinding() {
87 ReferenceObjectBindingBoServiceImplGenTest test = ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl);
88 test.test_createReferenceObjectBinding();
89 referenceObjectBinding = test.getReferenceObjectBinding();
90 assert(referenceObjectBinding != null);
91 assert(referenceObjectBinding.getId() != null);
92 }
93
94 @Test(expected = IllegalStateException.class)
95 public void test_createReferenceObjectBinding_fail_existing() {
96 test_createReferenceObjectBinding();
97 test_createReferenceObjectBinding();
98 }
99
100 @Test(expected = IllegalArgumentException.class)
101 public void test_createReferenceObjectBinding_null_fail() {
102 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_createReferenceObjectBinding_null_fail();
103 }
104
105 @Test
106 public void test_getReferenceObjectBinding() {
107 test_createReferenceObjectBinding();
108 ReferenceObjectBinding def = getReferenceObjectBinding();
109 ReferenceObjectBinding def2 = referenceObjectBindingBoServiceImpl.getReferenceObjectBinding(def.getId());
110 assert(def2 != null);
111 assert(def2.equals(def));
112 }
113
114 @Test
115 public void test_updateReferenceObjectBinding() {
116 test_createReferenceObjectBinding();
117 ReferenceObjectBinding def = getReferenceObjectBinding();
118 String id = def.getId();
119 assert(!"UpdateTest".equals(def.getCollectionName()));
120 ReferenceObjectBindingBo bo = referenceObjectBindingBoServiceImpl.from(def);
121 bo.setCollectionName("UpdateTest");
122 ReferenceObjectBinding updatedData = referenceObjectBindingBoServiceImpl.updateReferenceObjectBinding(ReferenceObjectBinding.Builder.create(bo).build());
123 ReferenceObjectBinding def2 = referenceObjectBindingBoServiceImpl.getReferenceObjectBinding(id);
124 assert(updatedData!=null);
125 assert("UpdateTest".equals(def2.getCollectionName()));
126 }
127
128 @Test(expected = IllegalArgumentException.class)
129 public void test_updateReferenceObjectBinding_null_fail() {
130 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_updateReferenceObjectBinding_null_fail();
131 }
132
133 @Test
134 public void test_deleteReferenceObjectBinding() {
135 test_createReferenceObjectBinding();
136 ReferenceObjectBinding def = getReferenceObjectBinding();
137 String id = def.getId();
138 referenceObjectBindingBoServiceImpl.deleteReferenceObjectBinding(id);
139 ReferenceObjectBinding def2 = referenceObjectBindingBoServiceImpl.getReferenceObjectBinding(id);
140 assert(def2 == null);
141 }
142
143 @Test(expected = IllegalArgumentException.class)
144 public void test_deleteReferenceObjectBinding_null_fail() {
145 (ReferenceObjectBindingBoServiceImplGenTest.create(referenceObjectBindingBoServiceImpl)).test_deleteReferenceObjectBinding_null_fail();
146 }
147
148 @Test
149 public void test_Find() {
150 QueryByCriteria.Builder query = QueryByCriteria.Builder.create();
151 query.setPredicates(PredicateFactory.equal("id", "ID"));
152 CriteriaLookupServiceImpl criteria = new CriteriaLookupServiceImpl();
153 criteria.setCriteriaLookupDao(new CriteriaLookupDaoProxy());
154 assert(referenceObjectBindingBoServiceImpl.findReferenceObjectBindingIds(query.build()).isEmpty());
155 test_createReferenceObjectBinding();
156 assert(!referenceObjectBindingBoServiceImpl.findReferenceObjectBindingIds(query.build()).isEmpty());
157 assert("ID".equals(referenceObjectBindingBoServiceImpl.findReferenceObjectBindingIds(query.build()).get(0)));
158 }
159
160 public ReferenceObjectBinding getReferenceObjectBinding() {
161 return referenceObjectBinding;
162 }
163 }