2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 package org.onap.portalapp.portal.service;
40 import static org.junit.Assert.assertEquals;
42 import java.util.Date;
43 import java.util.HashSet;
46 import javax.naming.NamingEnumeration;
47 import javax.naming.NamingException;
48 import javax.naming.directory.Attribute;
49 import javax.naming.directory.Attributes;
50 import javax.naming.directory.DirContext;
52 import org.hibernate.Session;
53 import org.hibernate.SessionFactory;
54 import org.hibernate.Transaction;
55 import org.junit.Before;
56 import org.junit.Test;
57 import org.junit.runner.RunWith;
58 import org.mockito.InjectMocks;
59 import org.mockito.Matchers;
60 import org.mockito.Mock;
61 import org.mockito.Mockito;
62 import org.mockito.MockitoAnnotations;
63 import org.onap.portalapp.portal.domain.EPApp;
64 import org.onap.portalapp.portal.domain.EPUser;
65 import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
66 import org.onap.portalsdk.core.command.support.SearchResult;
67 import org.onap.portalsdk.core.service.support.ServiceLocator;
68 import org.onap.portalsdk.core.util.SystemProperties;
69 import org.owasp.esapi.ESAPI;
70 import org.owasp.esapi.Encoder;
71 import org.powermock.api.mockito.PowerMockito;
72 import org.powermock.core.classloader.annotations.PrepareForTest;
73 import org.powermock.modules.junit4.PowerMockRunner;
75 @RunWith(PowerMockRunner.class)
76 @PrepareForTest({SystemProperties.class, ESAPI.class})
77 public class EPLdapServiceImplTest {
80 SessionFactory sessionFactory;
86 Transaction transaction;
89 ServiceLocator serviceLocator;
92 DirContext dirContext;
94 NullPointerException nullPointerException = new NullPointerException();
98 MockitoAnnotations.initMocks(this);
99 Mockito.when(sessionFactory.openSession()).thenReturn(session);
100 Mockito.when(session.beginTransaction()).thenReturn(transaction);
103 EPUser epUser = mockEPUser();
106 EPLdapServiceImpl epLdapServiceImpl = new EPLdapServiceImpl();
108 public EPApp mockApp() {
109 EPApp app = new EPApp();
111 app.setImageUrl("test");
112 app.setDescription("test");
113 app.setNotes("test");
116 app.setAppRestEndpoint("test");
117 app.setAlternateUrl("test");
119 app.setMlAppName("test");
120 app.setMlAppAdminId("test");
121 app.setUsername("test");
122 app.setAppPassword("test");
124 app.setEnabled(false);
125 app.setCentralAuth(true);
126 app.setUebKey("test");
127 app.setUebSecret("test");
128 app.setUebTopicName("test");
133 public EPUser mockEPUser() {
135 EPUser ePUser = new EPUser();
136 ePUser.setOrgId(null);
137 ePUser.setManagerId(null);
138 ePUser.setFirstName("test");
139 ePUser.setLastName("test");
140 ePUser.setMiddleInitial(null);
141 ePUser.setPhone(null);
143 ePUser.setCellular(null);
144 ePUser.setEmail(null);
145 ePUser.setAddressId(null);
146 ePUser.setAlertMethodCd(null);
147 ePUser.setHrid(null);
148 ePUser.setOrgUserId("guestT");
149 ePUser.setOrgCode(null);
150 ePUser.setAddress1(null);
151 ePUser.setAddress2(null);
152 ePUser.setCity(null);
153 ePUser.setState(null);
154 ePUser.setZipCode(null);
155 ePUser.setCountry(null);
156 ePUser.setOrgManagerUserId(null);
157 ePUser.setLocationClli(null);
158 ePUser.setBusinessCountryCode(null);
159 ePUser.setBusinessCountryName(null);
160 ePUser.setBusinessUnit(null);
161 ePUser.setBusinessUnitName(null);
162 ePUser.setDepartment(null);
163 ePUser.setDepartmentName(null);
164 ePUser.setCompanyCode(null);
165 ePUser.setCompany(null);
166 ePUser.setZipCodeSuffix(null);
167 ePUser.setJobTitle(null);
168 ePUser.setCommandChain(null);
169 ePUser.setSiloStatus(null);
170 ePUser.setCostCenter(null);
171 ePUser.setFinancialLocCode(null);
172 ePUser.setHrid("test");
173 ePUser.setOrgUserId("test");
174 ePUser.setOrgCode("test");
176 ePUser.setEmail("test.com");
177 ePUser.setLoginId(null);
178 ePUser.setLoginPwd(null);
179 Date date = new Date();
180 ePUser.setLastLoginDate(date);
181 ePUser.setActive(true);
182 ePUser.setInternal(false);
183 ePUser.setSelectedProfileId(null);
184 ePUser.setTimeZoneId(null);
185 ePUser.setOnline(true);
186 ePUser.setChatId(null);
187 ePUser.setUserApps(null);
188 ePUser.setPseudoRoles(null);
190 ePUser.setId((long) -1);
195 public void searchPostTest() throws Exception{
196 SearchResult expected = new SearchResult();
197 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
198 PowerMockito.mockStatic(SystemProperties.class);
199 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
200 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
201 PowerMockito.mockStatic(ESAPI.class);
202 Encoder encoder = PowerMockito.mock(Encoder.class);
203 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
204 Mockito.when(serviceLocator.getDirContext(
205 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
206 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
207 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
208 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
209 NamingEnumeration e = PowerMockito.mock(NamingEnumeration.class);
210 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
211 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
212 assertEquals(expected, actual);
216 public void searchPostNamingExceptionTest() throws Exception{
217 SearchResult expected = new SearchResult();
218 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
219 PowerMockito.mockStatic(SystemProperties.class);
220 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
221 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
222 PowerMockito.mockStatic(ESAPI.class);
223 Encoder encoder = PowerMockito.mock(Encoder.class);
224 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
225 Mockito.when(serviceLocator.getDirContext(
226 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
227 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
228 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
229 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
230 NamingEnumeration e = PowerMockito.mock(NamingEnumeration.class);
231 NamingException ne = new NamingException("test");
232 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenThrow(ne);
233 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
234 assertEquals(expected, actual);
238 public void searchPostExceptionTest() throws Exception{
239 SearchResult expected = new SearchResult();
240 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
241 PowerMockito.mockStatic(SystemProperties.class);
242 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
243 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
244 PowerMockito.mockStatic(ESAPI.class);
245 Encoder encoder = PowerMockito.mock(Encoder.class);
246 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
247 Mockito.when(serviceLocator.getDirContext(
248 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
249 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
250 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
251 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
252 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
253 assertEquals(expected, actual);
257 public void searchPostWhileTest() throws Exception{
258 SearchResult expected = new SearchResult();
259 PowerMockito.mockStatic(SystemProperties.class);
260 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
261 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
262 PowerMockito.mockStatic(ESAPI.class);
263 Encoder encoder = PowerMockito.mock(Encoder.class);
264 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
265 Mockito.when(serviceLocator.getDirContext(
266 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
267 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
268 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
269 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
270 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
271 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
272 Mockito.when(e.hasMore()).thenReturn(true);
273 Mockito.when(e.next()).thenReturn(sr);
274 Attributes attributes = Mockito.mock(Attributes.class);
275 Mockito.when(sr.getAttributes()).thenReturn(attributes);
276 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
277 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
278 assertEquals(expected, actual);
282 public void searchPostwhile2Test() throws Exception{
283 SearchResult expected = new SearchResult();
284 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
285 PowerMockito.mockStatic(SystemProperties.class);
286 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
287 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
288 PowerMockito.mockStatic(ESAPI.class);
289 Encoder encoder = PowerMockito.mock(Encoder.class);
290 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
291 Mockito.when(serviceLocator.getDirContext(
292 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
293 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
294 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
295 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
296 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
297 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
298 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
299 Mockito.when(e.hasMore()).thenReturn(true);
300 Mockito.when(e.next()).thenReturn(sr);
301 Attributes attributes = Mockito.mock(Attributes.class);
302 Mockito.when(sr.getAttributes()).thenReturn(attributes);
303 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
304 Mockito.when(attributes.getAll()).thenReturn(ef);
305 Mockito.when(ef.hasMore()).thenReturn(true);
306 Attribute attribute = Mockito.mock(Attribute.class);
307 Mockito.when(ef.next()).thenReturn(attribute);
308 Mockito.when(attribute.getAll()).thenReturn(ef);
309 Mockito.when(attribute.getID()).thenReturn("givenName");
311 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
312 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
313 assertEquals(actual, expected);
317 public void searchPostwhile3Test() throws Exception{
318 SearchResult expected = new SearchResult();
319 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
320 PowerMockito.mockStatic(SystemProperties.class);
321 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
322 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
323 PowerMockito.mockStatic(ESAPI.class);
324 Encoder encoder = PowerMockito.mock(Encoder.class);
325 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
326 Mockito.when(serviceLocator.getDirContext(
327 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
328 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
329 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
330 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
331 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
332 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
333 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
334 Mockito.when(e.hasMore()).thenReturn(true);
335 Mockito.when(e.next()).thenReturn(sr);
336 Attributes attributes = Mockito.mock(Attributes.class);
337 Mockito.when(sr.getAttributes()).thenReturn(attributes);
338 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
339 Mockito.when(attributes.getAll()).thenReturn(ef);
340 Mockito.when(ef.hasMore()).thenReturn(true);
341 Attribute attribute = Mockito.mock(Attribute.class);
342 Mockito.when(ef.next()).thenReturn(attribute);
343 Mockito.when(attribute.getAll()).thenReturn(ef);
344 Mockito.when(attribute.getID()).thenReturn("initials");
346 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
347 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
348 assertEquals(actual, expected);
352 public void searchPostwhile4Test() throws Exception{
353 SearchResult expected = new SearchResult();
354 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
355 PowerMockito.mockStatic(SystemProperties.class);
356 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
357 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
358 PowerMockito.mockStatic(ESAPI.class);
359 Encoder encoder = PowerMockito.mock(Encoder.class);
360 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
361 Mockito.when(serviceLocator.getDirContext(
362 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
363 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
364 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
365 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
366 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
367 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
368 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
369 Mockito.when(e.hasMore()).thenReturn(true);
370 Mockito.when(e.next()).thenReturn(sr);
371 Attributes attributes = Mockito.mock(Attributes.class);
372 Mockito.when(sr.getAttributes()).thenReturn(attributes);
373 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
374 Mockito.when(attributes.getAll()).thenReturn(ef);
375 Mockito.when(ef.hasMore()).thenReturn(true);
376 Attribute attribute = Mockito.mock(Attribute.class);
377 Mockito.when(ef.next()).thenReturn(attribute);
378 Mockito.when(attribute.getAll()).thenReturn(ef);
379 Mockito.when(attribute.getID()).thenReturn("sn");
381 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
382 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
383 assertEquals(actual, expected);
387 public void searchPostwhile5Test() throws Exception{
388 SearchResult expected = new SearchResult();
389 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
390 PowerMockito.mockStatic(SystemProperties.class);
391 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
392 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
393 PowerMockito.mockStatic(ESAPI.class);
394 Encoder encoder = PowerMockito.mock(Encoder.class);
395 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
396 Mockito.when(serviceLocator.getDirContext(
397 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
398 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
399 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
400 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
401 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
402 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
403 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
404 Mockito.when(e.hasMore()).thenReturn(true);
405 Mockito.when(e.next()).thenReturn(sr);
406 Attributes attributes = Mockito.mock(Attributes.class);
407 Mockito.when(sr.getAttributes()).thenReturn(attributes);
408 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
409 Mockito.when(attributes.getAll()).thenReturn(ef);
410 Mockito.when(ef.hasMore()).thenReturn(true);
411 Attribute attribute = Mockito.mock(Attribute.class);
412 Mockito.when(ef.next()).thenReturn(attribute);
413 Mockito.when(attribute.getAll()).thenReturn(ef);
414 Mockito.when(attribute.getID()).thenReturn("employeeNumber");
416 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
417 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
418 assertEquals(actual, expected);
422 public void searchPostwhile6Test() throws Exception{
423 SearchResult expected = new SearchResult();
424 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
425 PowerMockito.mockStatic(SystemProperties.class);
426 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
427 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
428 PowerMockito.mockStatic(ESAPI.class);
429 Encoder encoder = PowerMockito.mock(Encoder.class);
430 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
431 Mockito.when(serviceLocator.getDirContext(
432 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
433 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
434 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
435 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
436 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
437 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
438 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
439 Mockito.when(e.hasMore()).thenReturn(true);
440 Mockito.when(e.next()).thenReturn(sr);
441 Attributes attributes = Mockito.mock(Attributes.class);
442 Mockito.when(sr.getAttributes()).thenReturn(attributes);
443 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
444 Mockito.when(attributes.getAll()).thenReturn(ef);
445 Mockito.when(ef.hasMore()).thenReturn(true);
446 Attribute attribute = Mockito.mock(Attribute.class);
447 Mockito.when(ef.next()).thenReturn(attribute);
448 Mockito.when(attribute.getAll()).thenReturn(ef);
449 Mockito.when(attribute.getID()).thenReturn("mail");
451 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
452 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
453 assertEquals(actual, expected);
457 public void searchPostwhile7Test() throws Exception{
458 SearchResult expected = new SearchResult();
459 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
460 PowerMockito.mockStatic(SystemProperties.class);
461 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
462 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
463 PowerMockito.mockStatic(ESAPI.class);
464 Encoder encoder = PowerMockito.mock(Encoder.class);
465 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
466 Mockito.when(serviceLocator.getDirContext(
467 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
468 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
469 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
470 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
471 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
472 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
473 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
474 Mockito.when(e.hasMore()).thenReturn(true);
475 Mockito.when(e.next()).thenReturn(sr);
476 Attributes attributes = Mockito.mock(Attributes.class);
477 Mockito.when(sr.getAttributes()).thenReturn(attributes);
478 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
479 Mockito.when(attributes.getAll()).thenReturn(ef);
480 Mockito.when(ef.hasMore()).thenReturn(true);
481 Attribute attribute = Mockito.mock(Attribute.class);
482 Mockito.when(ef.next()).thenReturn(attribute);
483 Mockito.when(attribute.getAll()).thenReturn(ef);
484 Mockito.when(attribute.getID()).thenReturn("telephoneNumber");
485 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
486 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
487 assertEquals(actual, expected);
491 public void searchPostwhile8Test() throws Exception{
492 SearchResult expected = new SearchResult();
493 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
494 PowerMockito.mockStatic(SystemProperties.class);
495 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
496 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
497 PowerMockito.mockStatic(ESAPI.class);
498 Encoder encoder = PowerMockito.mock(Encoder.class);
499 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
500 Mockito.when(serviceLocator.getDirContext(
501 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
502 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
503 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
504 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
505 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
506 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
507 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
508 Mockito.when(e.hasMore()).thenReturn(true);
509 Mockito.when(e.next()).thenReturn(sr);
510 Attributes attributes = Mockito.mock(Attributes.class);
511 Mockito.when(sr.getAttributes()).thenReturn(attributes);
512 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
513 Mockito.when(attributes.getAll()).thenReturn(ef);
514 Mockito.when(ef.hasMore()).thenReturn(true);
515 Attribute attribute = Mockito.mock(Attribute.class);
516 Mockito.when(ef.next()).thenReturn(attribute);
517 Mockito.when(attribute.getAll()).thenReturn(ef);
518 Mockito.when(attribute.getID()).thenReturn("departmentNumber");
519 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
520 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
521 assertEquals(actual, expected);
525 public void searchPostwhile9Test() throws Exception{
526 SearchResult expected = new SearchResult();
527 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
528 PowerMockito.mockStatic(SystemProperties.class);
529 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
530 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
531 PowerMockito.mockStatic(ESAPI.class);
532 Encoder encoder = PowerMockito.mock(Encoder.class);
533 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
534 Mockito.when(serviceLocator.getDirContext(
535 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
536 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
537 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
538 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
539 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
540 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
541 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
542 Mockito.when(e.hasMore()).thenReturn(true);
543 Mockito.when(e.next()).thenReturn(sr);
544 Attributes attributes = Mockito.mock(Attributes.class);
545 Mockito.when(sr.getAttributes()).thenReturn(attributes);
546 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
547 Mockito.when(attributes.getAll()).thenReturn(ef);
548 Mockito.when(ef.hasMore()).thenReturn(true);
549 Attribute attribute = Mockito.mock(Attribute.class);
550 Mockito.when(ef.next()).thenReturn(attribute);
551 Mockito.when(attribute.getAll()).thenReturn(ef);
552 Mockito.when(attribute.getID()).thenReturn("a1");
553 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
554 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
555 assertEquals(actual, expected);
559 public void searchPostwhile10Test() throws Exception{
560 SearchResult expected = new SearchResult();
561 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
562 PowerMockito.mockStatic(SystemProperties.class);
563 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
564 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
565 PowerMockito.mockStatic(ESAPI.class);
566 Encoder encoder = PowerMockito.mock(Encoder.class);
567 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
568 Mockito.when(serviceLocator.getDirContext(
569 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
570 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
571 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
572 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
573 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
574 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
575 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
576 Mockito.when(e.hasMore()).thenReturn(true);
577 Mockito.when(e.next()).thenReturn(sr);
578 Attributes attributes = Mockito.mock(Attributes.class);
579 Mockito.when(sr.getAttributes()).thenReturn(attributes);
580 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
581 Mockito.when(attributes.getAll()).thenReturn(ef);
582 Mockito.when(ef.hasMore()).thenReturn(true);
583 Attribute attribute = Mockito.mock(Attribute.class);
584 Mockito.when(ef.next()).thenReturn(attribute);
585 Mockito.when(attribute.getAll()).thenReturn(ef);
586 Mockito.when(attribute.getID()).thenReturn("street");
587 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
588 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
589 assertEquals(actual, expected);
593 public void searchPostwhile11Test() throws Exception{
594 SearchResult expected = new SearchResult();
595 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
596 PowerMockito.mockStatic(SystemProperties.class);
597 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
598 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
599 PowerMockito.mockStatic(ESAPI.class);
600 Encoder encoder = PowerMockito.mock(Encoder.class);
601 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
602 Mockito.when(serviceLocator.getDirContext(
603 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
604 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
605 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
606 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
607 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
608 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
609 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
610 Mockito.when(e.hasMore()).thenReturn(true);
611 Mockito.when(e.next()).thenReturn(sr);
612 Attributes attributes = Mockito.mock(Attributes.class);
613 Mockito.when(sr.getAttributes()).thenReturn(attributes);
614 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
615 Mockito.when(attributes.getAll()).thenReturn(ef);
616 Mockito.when(ef.hasMore()).thenReturn(true);
617 Attribute attribute = Mockito.mock(Attribute.class);
618 Mockito.when(ef.next()).thenReturn(attribute);
619 Mockito.when(attribute.getAll()).thenReturn(ef);
620 Mockito.when(attribute.getID()).thenReturn("roomNumber");
621 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
622 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
623 assertEquals(actual, expected);
627 public void searchPostwhile12Test() throws Exception{
628 SearchResult expected = new SearchResult();
629 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
630 PowerMockito.mockStatic(SystemProperties.class);
631 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
632 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
633 PowerMockito.mockStatic(ESAPI.class);
634 Encoder encoder = PowerMockito.mock(Encoder.class);
635 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
636 Mockito.when(serviceLocator.getDirContext(
637 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
638 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
639 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
640 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
641 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
642 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
643 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
644 Mockito.when(e.hasMore()).thenReturn(true);
645 Mockito.when(e.next()).thenReturn(sr);
646 Attributes attributes = Mockito.mock(Attributes.class);
647 Mockito.when(sr.getAttributes()).thenReturn(attributes);
648 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
649 Mockito.when(attributes.getAll()).thenReturn(ef);
650 Mockito.when(ef.hasMore()).thenReturn(true);
651 Attribute attribute = Mockito.mock(Attribute.class);
652 Mockito.when(ef.next()).thenReturn(attribute);
653 Mockito.when(attribute.getAll()).thenReturn(ef);
654 Mockito.when(attribute.getID()).thenReturn("l");
655 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
656 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
657 assertEquals(actual, expected);
661 public void searchPostwhile13Test() throws Exception{
662 SearchResult expected = new SearchResult();
663 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
664 PowerMockito.mockStatic(SystemProperties.class);
665 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
666 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
667 PowerMockito.mockStatic(ESAPI.class);
668 Encoder encoder = PowerMockito.mock(Encoder.class);
669 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
670 Mockito.when(serviceLocator.getDirContext(
671 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
672 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
673 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
674 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
675 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
676 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
677 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
678 Mockito.when(e.hasMore()).thenReturn(true);
679 Mockito.when(e.next()).thenReturn(sr);
680 Attributes attributes = Mockito.mock(Attributes.class);
681 Mockito.when(sr.getAttributes()).thenReturn(attributes);
682 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
683 Mockito.when(attributes.getAll()).thenReturn(ef);
684 Mockito.when(ef.hasMore()).thenReturn(true);
685 Attribute attribute = Mockito.mock(Attribute.class);
686 Mockito.when(ef.next()).thenReturn(attribute);
687 Mockito.when(attribute.getAll()).thenReturn(ef);
688 Mockito.when(attribute.getID()).thenReturn("st");
689 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
690 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
691 assertEquals(actual, expected);
695 public void searchPostwhile14Test() throws Exception{
696 SearchResult expected = new SearchResult();
697 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
698 PowerMockito.mockStatic(SystemProperties.class);
699 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
700 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
701 PowerMockito.mockStatic(ESAPI.class);
702 Encoder encoder = PowerMockito.mock(Encoder.class);
703 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
704 Mockito.when(serviceLocator.getDirContext(
705 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
706 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
707 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
708 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
709 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
710 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
711 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
712 Mockito.when(e.hasMore()).thenReturn(true);
713 Mockito.when(e.next()).thenReturn(sr);
714 Attributes attributes = Mockito.mock(Attributes.class);
715 Mockito.when(sr.getAttributes()).thenReturn(attributes);
716 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
717 Mockito.when(attributes.getAll()).thenReturn(ef);
718 Mockito.when(ef.hasMore()).thenReturn(true);
719 Attribute attribute = Mockito.mock(Attribute.class);
720 Mockito.when(ef.next()).thenReturn(attribute);
721 Mockito.when(attribute.getAll()).thenReturn(ef);
722 Mockito.when(attribute.getID()).thenReturn("postalCode");
723 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
724 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
725 assertEquals(actual, expected);
729 public void searchPostwhile15Test() throws Exception{
730 SearchResult expected = new SearchResult();
731 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
732 PowerMockito.mockStatic(SystemProperties.class);
733 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
734 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
735 PowerMockito.mockStatic(ESAPI.class);
736 Encoder encoder = PowerMockito.mock(Encoder.class);
737 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
738 Mockito.when(serviceLocator.getDirContext(
739 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
740 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
741 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
742 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
743 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
744 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
745 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
746 Mockito.when(e.hasMore()).thenReturn(true);
747 Mockito.when(e.next()).thenReturn(sr);
748 Attributes attributes = Mockito.mock(Attributes.class);
749 Mockito.when(sr.getAttributes()).thenReturn(attributes);
750 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
751 Mockito.when(attributes.getAll()).thenReturn(ef);
752 Mockito.when(ef.hasMore()).thenReturn(true);
753 Attribute attribute = Mockito.mock(Attribute.class);
754 Mockito.when(ef.next()).thenReturn(attribute);
755 Mockito.when(attribute.getAll()).thenReturn(ef);
756 Mockito.when(attribute.getID()).thenReturn("zip4");
757 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
758 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
759 assertEquals(actual, expected);
763 public void searchPostwhile16Test() throws Exception{
764 SearchResult expected = new SearchResult();
765 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
766 PowerMockito.mockStatic(SystemProperties.class);
767 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
768 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
769 PowerMockito.mockStatic(ESAPI.class);
770 Encoder encoder = PowerMockito.mock(Encoder.class);
771 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
772 Mockito.when(serviceLocator.getDirContext(
773 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
774 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
775 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
776 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
777 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
778 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
779 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
780 Mockito.when(e.hasMore()).thenReturn(true);
781 Mockito.when(e.next()).thenReturn(sr);
782 Attributes attributes = Mockito.mock(Attributes.class);
783 Mockito.when(sr.getAttributes()).thenReturn(attributes);
784 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
785 Mockito.when(attributes.getAll()).thenReturn(ef);
786 Mockito.when(ef.hasMore()).thenReturn(true);
787 Attribute attribute = Mockito.mock(Attribute.class);
788 Mockito.when(ef.next()).thenReturn(attribute);
789 Mockito.when(attribute.getAll()).thenReturn(ef);
790 Mockito.when(attribute.getID()).thenReturn("physicalDeliveryOfficeName");
791 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
792 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
793 assertEquals(actual, expected);
797 public void searchPostwhile17Test() throws Exception{
798 SearchResult expected = new SearchResult();
799 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
800 PowerMockito.mockStatic(SystemProperties.class);
801 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
802 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
803 PowerMockito.mockStatic(ESAPI.class);
804 Encoder encoder = PowerMockito.mock(Encoder.class);
805 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
806 Mockito.when(serviceLocator.getDirContext(
807 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
808 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
809 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
810 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
811 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
812 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
813 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
814 Mockito.when(e.hasMore()).thenReturn(true);
815 Mockito.when(e.next()).thenReturn(sr);
816 Attributes attributes = Mockito.mock(Attributes.class);
817 Mockito.when(sr.getAttributes()).thenReturn(attributes);
818 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
819 Mockito.when(attributes.getAll()).thenReturn(ef);
820 Mockito.when(ef.hasMore()).thenReturn(true);
821 Attribute attribute = Mockito.mock(Attribute.class);
822 Mockito.when(ef.next()).thenReturn(attribute);
823 Mockito.when(attribute.getAll()).thenReturn(ef);
824 Mockito.when(attribute.getID()).thenReturn("bc");
825 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
826 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
827 assertEquals(actual, expected);
831 public void searchPostwhile18Test() throws Exception{
832 SearchResult expected = new SearchResult();
833 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
834 PowerMockito.mockStatic(SystemProperties.class);
835 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
836 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
837 PowerMockito.mockStatic(ESAPI.class);
838 Encoder encoder = PowerMockito.mock(Encoder.class);
839 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
840 Mockito.when(serviceLocator.getDirContext(
841 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
842 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
843 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
844 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
845 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
846 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
847 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
848 Mockito.when(e.hasMore()).thenReturn(true);
849 Mockito.when(e.next()).thenReturn(sr);
850 Attributes attributes = Mockito.mock(Attributes.class);
851 Mockito.when(sr.getAttributes()).thenReturn(attributes);
852 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
853 Mockito.when(attributes.getAll()).thenReturn(ef);
854 Mockito.when(ef.hasMore()).thenReturn(true);
855 Attribute attribute = Mockito.mock(Attribute.class);
856 Mockito.when(ef.next()).thenReturn(attribute);
857 Mockito.when(attribute.getAll()).thenReturn(ef);
858 Mockito.when(attribute.getID()).thenReturn("friendlyCountryName");
859 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
860 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
861 assertEquals(actual, expected);
865 public void searchPostwhile19Test() throws Exception{
866 SearchResult expected = new SearchResult();
867 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
868 PowerMockito.mockStatic(SystemProperties.class);
869 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
870 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
871 PowerMockito.mockStatic(ESAPI.class);
872 Encoder encoder = PowerMockito.mock(Encoder.class);
873 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
874 Mockito.when(serviceLocator.getDirContext(
875 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
876 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
877 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
878 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
879 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
880 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
881 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
882 Mockito.when(e.hasMore()).thenReturn(true);
883 Mockito.when(e.next()).thenReturn(sr);
884 Attributes attributes = Mockito.mock(Attributes.class);
885 Mockito.when(sr.getAttributes()).thenReturn(attributes);
886 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
887 Mockito.when(attributes.getAll()).thenReturn(ef);
888 Mockito.when(ef.hasMore()).thenReturn(true);
889 Attribute attribute = Mockito.mock(Attribute.class);
890 Mockito.when(ef.next()).thenReturn(attribute);
891 Mockito.when(attribute.getAll()).thenReturn(ef);
892 Mockito.when(attribute.getID()).thenReturn("bd");
893 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
894 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
895 assertEquals(actual, expected);
899 public void searchPostwhile20Test() throws Exception{
900 SearchResult expected = new SearchResult();
901 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
902 PowerMockito.mockStatic(SystemProperties.class);
903 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
904 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
905 PowerMockito.mockStatic(ESAPI.class);
906 Encoder encoder = PowerMockito.mock(Encoder.class);
907 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
908 Mockito.when(serviceLocator.getDirContext(
909 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
910 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
911 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
912 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
913 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
914 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
915 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
916 Mockito.when(e.hasMore()).thenReturn(true);
917 Mockito.when(e.next()).thenReturn(sr);
918 Attributes attributes = Mockito.mock(Attributes.class);
919 Mockito.when(sr.getAttributes()).thenReturn(attributes);
920 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
921 Mockito.when(attributes.getAll()).thenReturn(ef);
922 Mockito.when(ef.hasMore()).thenReturn(true);
923 Attribute attribute = Mockito.mock(Attribute.class);
924 Mockito.when(ef.next()).thenReturn(attribute);
925 Mockito.when(attribute.getAll()).thenReturn(ef);
926 Mockito.when(attribute.getID()).thenReturn("bdname");
927 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
928 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
929 assertEquals(actual, expected);
933 public void searchPostwhile21Test() throws Exception{
934 SearchResult expected = new SearchResult();
935 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
936 PowerMockito.mockStatic(SystemProperties.class);
937 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
938 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
939 PowerMockito.mockStatic(ESAPI.class);
940 Encoder encoder = PowerMockito.mock(Encoder.class);
941 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
942 Mockito.when(serviceLocator.getDirContext(
943 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
944 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
945 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
946 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
947 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
948 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
949 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
950 Mockito.when(e.hasMore()).thenReturn(true);
951 Mockito.when(e.next()).thenReturn(sr);
952 Attributes attributes = Mockito.mock(Attributes.class);
953 Mockito.when(sr.getAttributes()).thenReturn(attributes);
954 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
955 Mockito.when(attributes.getAll()).thenReturn(ef);
956 Mockito.when(ef.hasMore()).thenReturn(true);
957 Attribute attribute = Mockito.mock(Attribute.class);
958 Mockito.when(ef.next()).thenReturn(attribute);
959 Mockito.when(attribute.getAll()).thenReturn(ef);
960 Mockito.when(attribute.getID()).thenReturn("jtname");
961 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
962 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
963 assertEquals(actual, expected);
967 public void searchPostwhile22Test() throws Exception{
968 SearchResult expected = new SearchResult();
969 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
970 PowerMockito.mockStatic(SystemProperties.class);
971 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
972 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
973 PowerMockito.mockStatic(ESAPI.class);
974 Encoder encoder = PowerMockito.mock(Encoder.class);
975 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
976 Mockito.when(serviceLocator.getDirContext(
977 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
978 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
979 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
980 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
981 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
982 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
983 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
984 Mockito.when(e.hasMore()).thenReturn(true);
985 Mockito.when(e.next()).thenReturn(sr);
986 Attributes attributes = Mockito.mock(Attributes.class);
987 Mockito.when(sr.getAttributes()).thenReturn(attributes);
988 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
989 Mockito.when(attributes.getAll()).thenReturn(ef);
990 Mockito.when(ef.hasMore()).thenReturn(true);
991 Attribute attribute = Mockito.mock(Attribute.class);
992 Mockito.when(ef.next()).thenReturn(attribute);
993 Mockito.when(attribute.getAll()).thenReturn(ef);
994 Mockito.when(attribute.getID()).thenReturn("mgrid");
995 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
996 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
997 assertEquals(actual, expected);
1001 public void searchPostwhile23Test() throws Exception{
1002 SearchResult expected = new SearchResult();
1003 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1004 PowerMockito.mockStatic(SystemProperties.class);
1005 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1006 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1007 PowerMockito.mockStatic(ESAPI.class);
1008 Encoder encoder = PowerMockito.mock(Encoder.class);
1009 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1010 Mockito.when(serviceLocator.getDirContext(
1011 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1012 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1013 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1014 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1015 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1016 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1017 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1018 Mockito.when(e.hasMore()).thenReturn(true);
1019 Mockito.when(e.next()).thenReturn(sr);
1020 Attributes attributes = Mockito.mock(Attributes.class);
1021 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1022 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1023 Mockito.when(attributes.getAll()).thenReturn(ef);
1024 Mockito.when(ef.hasMore()).thenReturn(true);
1025 Attribute attribute = Mockito.mock(Attribute.class);
1026 Mockito.when(ef.next()).thenReturn(attribute);
1027 Mockito.when(attribute.getAll()).thenReturn(ef);
1028 Mockito.when(attribute.getID()).thenReturn("a2");
1029 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1030 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1031 assertEquals(actual, expected);
1035 public void searchPostwhile24Test() throws Exception{
1036 SearchResult expected = new SearchResult();
1037 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1038 PowerMockito.mockStatic(SystemProperties.class);
1039 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1040 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1041 PowerMockito.mockStatic(ESAPI.class);
1042 Encoder encoder = PowerMockito.mock(Encoder.class);
1043 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1044 Mockito.when(serviceLocator.getDirContext(
1045 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1046 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1047 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1048 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1049 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1050 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1051 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1052 Mockito.when(e.hasMore()).thenReturn(true);
1053 Mockito.when(e.next()).thenReturn(sr);
1054 Attributes attributes = Mockito.mock(Attributes.class);
1055 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1056 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1057 Mockito.when(attributes.getAll()).thenReturn(ef);
1058 Mockito.when(ef.hasMore()).thenReturn(true);
1059 Attribute attribute = Mockito.mock(Attribute.class);
1060 Mockito.when(ef.next()).thenReturn(attribute);
1061 Mockito.when(attribute.getAll()).thenReturn(ef);
1062 Mockito.when(attribute.getID()).thenReturn("compcode");
1063 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1064 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1065 assertEquals(actual, expected);
1069 public void searchPostwhile25Test() throws Exception{
1070 SearchResult expected = new SearchResult();
1071 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1072 PowerMockito.mockStatic(SystemProperties.class);
1073 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1074 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1075 PowerMockito.mockStatic(ESAPI.class);
1076 Encoder encoder = PowerMockito.mock(Encoder.class);
1077 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1078 Mockito.when(serviceLocator.getDirContext(
1079 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1080 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1081 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1082 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1083 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1084 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1085 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1086 Mockito.when(e.hasMore()).thenReturn(true);
1087 Mockito.when(e.next()).thenReturn(sr);
1088 Attributes attributes = Mockito.mock(Attributes.class);
1089 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1090 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1091 Mockito.when(attributes.getAll()).thenReturn(ef);
1092 Mockito.when(ef.hasMore()).thenReturn(true);
1093 Attribute attribute = Mockito.mock(Attribute.class);
1094 Mockito.when(ef.next()).thenReturn(attribute);
1095 Mockito.when(attribute.getAll()).thenReturn(ef);
1096 Mockito.when(attribute.getID()).thenReturn("compdesc");
1097 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1098 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1099 assertEquals(actual, expected);
1103 public void searchPostwhile26Test() throws Exception{
1104 SearchResult expected = new SearchResult();
1105 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1106 PowerMockito.mockStatic(SystemProperties.class);
1107 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1108 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1109 PowerMockito.mockStatic(ESAPI.class);
1110 Encoder encoder = PowerMockito.mock(Encoder.class);
1111 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1112 Mockito.when(serviceLocator.getDirContext(
1113 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1114 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1115 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1116 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1117 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1118 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1119 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1120 Mockito.when(e.hasMore()).thenReturn(true);
1121 Mockito.when(e.next()).thenReturn(sr);
1122 Attributes attributes = Mockito.mock(Attributes.class);
1123 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1124 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1125 Mockito.when(attributes.getAll()).thenReturn(ef);
1126 Mockito.when(ef.hasMore()).thenReturn(true);
1127 Attribute attribute = Mockito.mock(Attribute.class);
1128 Mockito.when(ef.next()).thenReturn(attribute);
1129 Mockito.when(attribute.getAll()).thenReturn(ef);
1130 Mockito.when(attribute.getID()).thenReturn("bu");
1131 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1132 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1133 assertEquals(actual, expected);
1137 public void searchPostwhile27Test() throws Exception{
1138 SearchResult expected = new SearchResult();
1139 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1140 PowerMockito.mockStatic(SystemProperties.class);
1141 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1142 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1143 PowerMockito.mockStatic(ESAPI.class);
1144 Encoder encoder = PowerMockito.mock(Encoder.class);
1145 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1146 Mockito.when(serviceLocator.getDirContext(
1147 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1148 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1149 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1150 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1151 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1152 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1153 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1154 Mockito.when(e.hasMore()).thenReturn(true);
1155 Mockito.when(e.next()).thenReturn(sr);
1156 Attributes attributes = Mockito.mock(Attributes.class);
1157 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1158 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1159 Mockito.when(attributes.getAll()).thenReturn(ef);
1160 Mockito.when(ef.hasMore()).thenReturn(true);
1161 Attribute attribute = Mockito.mock(Attribute.class);
1162 Mockito.when(ef.next()).thenReturn(attribute);
1163 Mockito.when(attribute.getAll()).thenReturn(ef);
1164 Mockito.when(attribute.getID()).thenReturn("buname");
1165 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1166 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1167 assertEquals(actual, expected);
1171 public void searchPostwhile28Test() throws Exception{
1172 SearchResult expected = new SearchResult();
1173 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1174 PowerMockito.mockStatic(SystemProperties.class);
1175 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1176 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1177 PowerMockito.mockStatic(ESAPI.class);
1178 Encoder encoder = PowerMockito.mock(Encoder.class);
1179 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1180 Mockito.when(serviceLocator.getDirContext(
1181 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1182 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1183 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1184 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1185 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1186 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1187 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1188 Mockito.when(e.hasMore()).thenReturn(true);
1189 Mockito.when(e.next()).thenReturn(sr);
1190 Attributes attributes = Mockito.mock(Attributes.class);
1191 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1192 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1193 Mockito.when(attributes.getAll()).thenReturn(ef);
1194 Mockito.when(ef.hasMore()).thenReturn(true);
1195 Attribute attribute = Mockito.mock(Attribute.class);
1196 Mockito.when(ef.next()).thenReturn(attribute);
1197 Mockito.when(attribute.getAll()).thenReturn(ef);
1198 Mockito.when(attribute.getID()).thenReturn("silo");
1199 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1200 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1201 assertEquals(actual, expected);
1205 public void searchPostwhile29Test() throws Exception{
1206 SearchResult expected = new SearchResult();
1207 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1208 PowerMockito.mockStatic(SystemProperties.class);
1209 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1210 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1211 PowerMockito.mockStatic(ESAPI.class);
1212 Encoder encoder = PowerMockito.mock(Encoder.class);
1213 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1214 Mockito.when(serviceLocator.getDirContext(
1215 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1216 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1217 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1218 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1219 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1220 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1221 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1222 Mockito.when(e.hasMore()).thenReturn(true);
1223 Mockito.when(e.next()).thenReturn(sr);
1224 Attributes attributes = Mockito.mock(Attributes.class);
1225 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1226 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1227 Mockito.when(attributes.getAll()).thenReturn(ef);
1228 Mockito.when(ef.hasMore()).thenReturn(true);
1229 Attribute attribute = Mockito.mock(Attribute.class);
1230 Mockito.when(ef.next()).thenReturn(attribute);
1231 Mockito.when(attribute.getAll()).thenReturn(ef);
1232 Mockito.when(attribute.getID()).thenReturn("costcenter");
1233 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1234 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1235 assertEquals(actual, expected);
1239 public void searchPostwhile30Test() throws Exception{
1240 SearchResult expected = new SearchResult();
1241 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1242 PowerMockito.mockStatic(SystemProperties.class);
1243 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1244 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1245 PowerMockito.mockStatic(ESAPI.class);
1246 Encoder encoder = PowerMockito.mock(Encoder.class);
1247 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1248 Mockito.when(serviceLocator.getDirContext(
1249 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1250 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1251 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1252 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1253 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1254 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1255 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1256 Mockito.when(e.hasMore()).thenReturn(true);
1257 Mockito.when(e.next()).thenReturn(sr);
1258 Attributes attributes = Mockito.mock(Attributes.class);
1259 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1260 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1261 Mockito.when(attributes.getAll()).thenReturn(ef);
1262 Mockito.when(ef.hasMore()).thenReturn(true);
1263 Attribute attribute = Mockito.mock(Attribute.class);
1264 Mockito.when(ef.next()).thenReturn(attribute);
1265 Mockito.when(attribute.getAll()).thenReturn(ef);
1266 Mockito.when(attribute.getID()).thenReturn("b2");
1267 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1268 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1269 assertEquals(actual, expected);
1273 public void searchPostwhile31Test() throws Exception{
1274 SearchResult expected = new SearchResult();
1275 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1276 PowerMockito.mockStatic(SystemProperties.class);
1277 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1278 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1279 PowerMockito.mockStatic(ESAPI.class);
1280 Encoder encoder = PowerMockito.mock(Encoder.class);
1281 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1282 Mockito.when(serviceLocator.getDirContext(
1283 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1284 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1285 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1286 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1287 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1288 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1289 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1290 Mockito.when(e.hasMore()).thenReturn(true);
1291 Mockito.when(e.next()).thenReturn(sr);
1292 Attributes attributes = Mockito.mock(Attributes.class);
1293 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1294 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1295 NamingException ne = new NamingException();
1296 Mockito.when(ef.hasMore()).thenReturn(true);
1297 Attribute attribute = Mockito.mock(Attribute.class);
1298 Mockito.when(ef.next()).thenReturn(attribute);
1299 Mockito.when(attribute.getAll()).thenThrow(ne);
1300 Mockito.when(attributes.getAll()).thenReturn(ef);
1301 Mockito.when(attribute.getID()).thenReturn("b2");
1302 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1303 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1304 assertEquals(actual, expected);
1308 public void searchPostWhileCountTest() throws Exception{
1309 SearchResult expected = new SearchResult();
1310 expected.setDataSize(123);
1311 StringBuffer filterClause = new StringBuffer("(&(objectClass=*)");
1312 PowerMockito.mockStatic(SystemProperties.class);
1313 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_PROVIDER_URL)).thenReturn("http://todo_enter_ush_ticket_url");
1314 Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.POST_SECURITY_PRINCIPAL)).thenReturn("POST_SECURITY_PRINCIPAL");
1315 Mockito.when(SystemProperties.getProperty(SystemProperties.POST_MAX_RESULT_SIZE)).thenReturn("0");
1316 PowerMockito.mockStatic(ESAPI.class);
1317 Encoder encoder = PowerMockito.mock(Encoder.class);
1318 PowerMockito.when(ESAPI.encoder()).thenReturn(encoder);
1319 Mockito.when(serviceLocator.getDirContext(
1320 SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY),
1321 SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL),
1322 SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL))).thenReturn(dirContext);
1323 PowerMockito.when(encoder.encodeForDN(Matchers.anyString())).thenReturn("test");
1324 Set<javax.naming.directory.SearchResult> set = new HashSet<>();
1325 javax.naming.directory.SearchResult sr = Mockito.mock(javax.naming.directory.SearchResult.class);
1326 NamingEnumeration e = Mockito.mock(NamingEnumeration.class);
1327 Mockito.when(e.hasMore()).thenReturn(true);
1328 Mockito.when(e.next()).thenReturn(sr);
1329 Attributes attributes = Mockito.mock(Attributes.class);
1330 Mockito.when(sr.getAttributes()).thenReturn(attributes);
1331 NamingEnumeration ef = Mockito.mock(NamingEnumeration.class);
1332 NamingException ne = new NamingException();
1333 Mockito.when(ef.hasMore()).thenReturn(true);
1334 Attribute attribute = Mockito.mock(Attribute.class);
1335 Mockito.when(ef.next()).thenReturn(attribute);
1336 Mockito.when(attribute.getAll()).thenThrow(ne);
1337 Mockito.when(attributes.getAll()).thenReturn(ef);
1338 Mockito.when(attribute.getID()).thenReturn("b2");
1339 Mockito.when(dirContext.search(Matchers.anyString(),Matchers.anyString(),Matchers.anyObject())).thenReturn(e);
1340 SearchResult actual = epLdapServiceImpl.searchPost(epUser, "test", "test", "test", 123, 123, 123);
1341 assertEquals(actual.getDataSize(), expected.getDataSize());