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