1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service;
17
18 import org.junit.Test;
19 import org.kuali.rice.krad.data.jpa.testbo.TestDataObject;
20 import org.kuali.rice.krad.test.document.bo.Account;
21 import org.kuali.rice.test.BaselineTestCase;
22 import org.kuali.rice.test.data.PerTestUnitTestData;
23 import org.kuali.rice.test.data.UnitTestData;
24 import org.kuali.rice.test.data.UnitTestFile;
25 import org.kuali.rice.test.data.UnitTestSql;
26 import org.kuali.rice.krad.test.KRADTestCase;
27
28 import java.util.Collection;
29 import java.util.HashMap;
30 import java.util.Map;
31
32 import static org.junit.Assert.assertEquals;
33 import static org.junit.Assert.assertTrue;
34
35
36
37
38
39
40
41
42
43
44 @PerTestUnitTestData(
45 value = @UnitTestData(
46 order = {UnitTestData.Type.SQL_STATEMENTS, UnitTestData.Type.SQL_FILES},
47 sqlStatements = {
48 @UnitTestSql("delete from trv_acct where acct_fo_id = '1'")
49 ,@UnitTestSql("delete from trv_acct_type")
50 ,@UnitTestSql("delete from krtst_test_table_t")
51 },
52 sqlFiles = {
53 @UnitTestFile(filename = "classpath:testAccountType.sql", delimiter = ";")
54 ,@UnitTestFile(filename = "classpath:testAccounts.sql", delimiter = ";")
55 ,@UnitTestFile(filename = "classpath:testDataObjects.sql", delimiter = ";")
56 }
57 ),
58 tearDown = @UnitTestData(
59 sqlStatements = {
60 @UnitTestSql("delete from trv_acct where acct_fo_id = '1'")
61 ,@UnitTestSql("delete from krtst_test_table_t")
62 }
63 )
64 )
65 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
66 public class LookupServiceTest extends KRADTestCase {
67
68
69 protected <T> Collection<T> findCollectionBySearchHelper(Class<T> clazz, Map<String, String> formProps, boolean unbounded) {
70 return KRADServiceLocatorWeb.getLookupService().findCollectionBySearchHelper(clazz, formProps, unbounded);
71 }
72
73 protected <T> Collection<T> findCollectionBySearch(Class<T> clazz, Map<String, String> formProps) {
74 return KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(clazz, formProps);
75 }
76
77 protected <T> Collection<T> findCollectionBySearchUnbounded(Class<T> clazz, Map<String, String> formProps) {
78 return KRADServiceLocatorWeb.getLookupService().findCollectionBySearchUnbounded(clazz, formProps);
79 }
80
81
82
83
84
85
86 @Test
87 public void testLookupReturnLimits_Account() throws Exception {
88 Map formProps = new HashMap();
89 Collection travelAccounts = findCollectionBySearchHelper(Account.class, formProps, false);
90 assertEquals(200, travelAccounts.size());
91
92 travelAccounts = findCollectionBySearch(Account.class, formProps);
93 assertEquals(200, travelAccounts.size());
94 }
95
96
97
98
99
100
101 @Test
102 public void testLookupReturnLimits_TestDataObject() throws Exception {
103 Map formProps = new HashMap();
104 Collection testDataObjects = findCollectionBySearchHelper(TestDataObject.class, formProps, false);
105 assertEquals(200, testDataObjects.size());
106
107 testDataObjects = findCollectionBySearch(TestDataObject.class, formProps);
108 assertEquals(200, testDataObjects.size());
109 }
110
111
112
113
114
115
116 @Test
117 public void testLookupReturnDefaultLimit() throws Exception {
118 Map formProps = new HashMap();
119 Collection travelAccounts = findCollectionBySearchHelper(Account.class, formProps, false);
120 assertEquals(200, travelAccounts.size());
121
122 travelAccounts = findCollectionBySearch(Account.class, formProps);
123 assertEquals(200, travelAccounts.size());
124 }
125
126
127
128
129
130
131 @Test
132 public void testLookupReturnDefaultUnbounded_Account() throws Exception {
133 Map formProps = new HashMap();
134 Collection travelAccounts = findCollectionBySearchHelper(Account.class, formProps, true);
135 int size = travelAccounts.size();
136 assertTrue("# of Travel Accounts should be > 200", size > 200);
137
138 travelAccounts = findCollectionBySearchUnbounded(Account.class, formProps);
139 size = travelAccounts.size();
140 assertTrue("# of Travel Accounts should be > 200", size > 200);
141 }
142
143
144
145
146
147
148 @Test
149 public void testLookupReturnDefaultUnbounded_TestDataObject() throws Exception {
150 Map formProps = new HashMap();
151 Collection testDataObjects = findCollectionBySearchHelper(TestDataObject.class, formProps, true);
152 int size = testDataObjects.size();
153 assertTrue("# of Test Data objects should be > 200", size > 200);
154
155 testDataObjects = findCollectionBySearchUnbounded(TestDataObject.class, formProps);
156 size = testDataObjects.size();
157 assertTrue("# of Test Data objects should be > 200", size > 200);
158 }
159
160 }