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.test.document.bo.Account;
20 import org.kuali.rice.krad.test.document.bo.AccountManager;
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.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 between 101 and 301")
49 ,@UnitTestSql("delete from trv_acct_fo where acct_fo_id between 101 and 301")
50 },
51 sqlFiles = {
52 @UnitTestFile(filename = "classpath:testAccountManagers.sql", delimiter = ";")
53 , @UnitTestFile(filename = "classpath:testAccounts.sql", delimiter = ";")
54 }
55 ),
56 tearDown = @UnitTestData(
57 sqlStatements = {
58 @UnitTestSql("delete from trv_acct where acct_fo_id between 101 and 301")
59 ,@UnitTestSql("delete from trv_acct_fo where acct_fo_id between 101 and 301")
60 }
61 )
62 )
63 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
64 public class LookupServiceTest extends KRADTestCase {
65
66 public LookupServiceTest() {}
67
68
69
70
71
72
73 @Test
74 public void testLookupReturnLimits() throws Exception {
75 LookupService lookupService = KRADServiceLocatorWeb.getLookupService();
76 Map formProps = new HashMap();
77 Collection accountManagers = lookupService.findCollectionBySearchHelper(AccountManager.class, formProps, false);
78 assertEquals(90, accountManagers.size());
79
80 accountManagers = null;
81 accountManagers = lookupService.findCollectionBySearch(AccountManager.class, formProps);
82 assertEquals(90, accountManagers.size());
83 }
84
85
86
87
88
89
90 @Test
91 public void testLookupReturnDefaultLimit() throws Exception {
92 LookupService lookupService = KRADServiceLocatorWeb.getLookupService();
93 Map formProps = new HashMap();
94 Collection travelAccounts = lookupService.findCollectionBySearchHelper(Account.class, formProps, false);
95 assertEquals(200, travelAccounts.size());
96
97 travelAccounts = null;
98 travelAccounts = lookupService.findCollectionBySearch(Account.class, formProps);
99 assertEquals(200, travelAccounts.size());
100 }
101
102
103
104
105
106
107 @Test
108 public void testLookupReturnDefaultUnbounded() throws Exception {
109 LookupService lookupService = KRADServiceLocatorWeb.getLookupService();
110 Map formProps = new HashMap();
111 Collection accountManagers = lookupService.findCollectionBySearchHelper(AccountManager.class, formProps, true);
112 int size = accountManagers.size();
113 assertTrue("# of Fiscal Officers should be > 200", size > 200);
114
115 accountManagers = null;
116 accountManagers = lookupService.findCollectionBySearchUnbounded(AccountManager.class, formProps);
117 size = accountManagers.size();
118 assertTrue("# of Fiscal Officers should be > 200", size > 200);
119 }
120
121
122
123
124
125
126 @Test
127 public void testLookupReturnDefaultUnbounded2() throws Exception {
128 LookupService lookupService = KRADServiceLocatorWeb.getLookupService();
129 Map formProps = new HashMap();
130 Collection travelAccounts = lookupService.findCollectionBySearchHelper(Account.class, formProps, true);
131 int size = travelAccounts.size();
132 assertTrue("# of Travel Accounts should be > 200", size > 200);
133
134 travelAccounts = null;
135 travelAccounts = lookupService.findCollectionBySearchUnbounded(Account.class, formProps);
136 size = travelAccounts.size();
137 assertTrue("# of Travel Accounts should be > 200", size > 200);
138 }
139
140 }