@Test @Ignore public void testExecute() { List<Endpoint> endpoints = new ArrayList<>(); SearchRequest searchRequest = mock(SearchRequest.class); Endpoint endpoint1 = mock(Endpoint.class); Endpoint endpoint2 = mock(Endpoint.class); endpoints.add(endpoint1); endpoints.add(endpoint2); LdapConnectionResult ldapConnectionResult = mock(LdapConnectionResult.class); LdapConnection ldapConnection = mock(LdapNetworkConnection.class); ldapConnectionResult.setConnection(ldapConnection); RoundtripResult roundtripResult = mock(RoundtripResult.class); when(queryRequest.getEndpoints()).thenReturn(endpoints); doReturn(driver).when(queryRequestNonPagedExecutor).driverGetInstance(); doReturn(roundtripResult).when(queryRequestNonPagedExecutor).collectData(ldapConnection, searchRequest); when(driver.connect(any(Endpoint.class))).thenReturn(ldapConnectionResult); when(ldapConnectionResult.getConnection()).thenReturn(ldapConnection); when(ldapConnectionResult.connectionSucceeded()).thenReturn(true); queryRequestNonPagedExecutor.execute(); verify(endpoint1, times(2)).getBaseSearchPath(); verify(endpoint2, times(2)).getBaseSearchPath(); verify(driver, times(endpoints.size())).connect(any(Endpoint.class)); verify(queryRequestNonPagedExecutor, times(endpoints.size())).collectData(any(LdapNetworkConnection.class), any(SearchRequest.class)); verify(endpoint1, times(1)).setDestinationType(any()); }
@Override QueryResponse execute() { QueryResponse response = new QueryResponse(); List<PartitionResponse> result = new ArrayList<>(); for (Endpoint endpoint : queryRequest.getEndpoints()) { String host = endpoint.getHost(); try { LOGGER.debug("Executing request for: " + host); PartitionResponse partitionResponse = new PartitionResponse(); result.add(partitionResponse); partitionResponse.setEndpoint(endpoint); LdapConnectionResult ldapConnectionResult = driverGetInstance().connect(endpoint); String baseSearchPath = tryResolveBasePath(ldapConnectionResult.getConnection(), endpoint.getBaseSearchPath()); endpoint.setBaseSearchPath(baseSearchPath); endpoint.setDestinationType(ldapConnectionResult.getDestinationType()); endpoint.setBaseSearchPath(baseSearchPath); partitionResponse.setStatus(ldapConnectionResult.getStatuses()); RoundtripResult roundtripResult = query(ldapConnectionResult.getConnection(), baseSearchPath); if (roundtripResult != null && roundtripResult.getData() != null) partitionResponse.setData(parserGetInstance().toEntityResponse(roundtripResult.getData(), queryRequest.getRequestedFields())); } catch (LdapException | BaseException e) { LOGGER.error("Query Execution failed for Endpoint: " + host, e); result.get(result.size() - 1).addStatus(host, new Oops(e)); if (!Utils.isEmpty(endpoint.getSecondaryHost())) { result.get(result.size() - 1).addStatus(endpoint.getSecondaryHost(), new Oops(e)); } endpoint.setDestinationType(DestinationType.NONE); } LOGGER.debug(result.size() + " results found for: " + host); } response.addPartitionResponse(result); return response; }
QueryRequestNonPagedExecutor extends QueryRequestExecutor { @Override QueryResponse execute() { QueryResponse response = new QueryResponse(); List<PartitionResponse> result = new ArrayList<>(); for (Endpoint endpoint : queryRequest.getEndpoints()) { String host = endpoint.getHost(); try { LOGGER.debug("Executing request for: " + host); PartitionResponse partitionResponse = new PartitionResponse(); result.add(partitionResponse); partitionResponse.setEndpoint(endpoint); LdapConnectionResult ldapConnectionResult = driverGetInstance().connect(endpoint); String baseSearchPath = tryResolveBasePath(ldapConnectionResult.getConnection(), endpoint.getBaseSearchPath()); endpoint.setBaseSearchPath(baseSearchPath); endpoint.setDestinationType(ldapConnectionResult.getDestinationType()); endpoint.setBaseSearchPath(baseSearchPath); partitionResponse.setStatus(ldapConnectionResult.getStatuses()); RoundtripResult roundtripResult = query(ldapConnectionResult.getConnection(), baseSearchPath); if (roundtripResult != null && roundtripResult.getData() != null) partitionResponse.setData(parserGetInstance().toEntityResponse(roundtripResult.getData(), queryRequest.getRequestedFields())); } catch (LdapException | BaseException e) { LOGGER.error("Query Execution failed for Endpoint: " + host, e); result.get(result.size() - 1).addStatus(host, new Oops(e)); if (!Utils.isEmpty(endpoint.getSecondaryHost())) { result.get(result.size() - 1).addStatus(endpoint.getSecondaryHost(), new Oops(e)); } endpoint.setDestinationType(DestinationType.NONE); } LOGGER.debug(result.size() + " results found for: " + host); } response.addPartitionResponse(result); return response; } }
QueryRequestNonPagedExecutor extends QueryRequestExecutor { @Override QueryResponse execute() { QueryResponse response = new QueryResponse(); List<PartitionResponse> result = new ArrayList<>(); for (Endpoint endpoint : queryRequest.getEndpoints()) { String host = endpoint.getHost(); try { LOGGER.debug("Executing request for: " + host); PartitionResponse partitionResponse = new PartitionResponse(); result.add(partitionResponse); partitionResponse.setEndpoint(endpoint); LdapConnectionResult ldapConnectionResult = driverGetInstance().connect(endpoint); String baseSearchPath = tryResolveBasePath(ldapConnectionResult.getConnection(), endpoint.getBaseSearchPath()); endpoint.setBaseSearchPath(baseSearchPath); endpoint.setDestinationType(ldapConnectionResult.getDestinationType()); endpoint.setBaseSearchPath(baseSearchPath); partitionResponse.setStatus(ldapConnectionResult.getStatuses()); RoundtripResult roundtripResult = query(ldapConnectionResult.getConnection(), baseSearchPath); if (roundtripResult != null && roundtripResult.getData() != null) partitionResponse.setData(parserGetInstance().toEntityResponse(roundtripResult.getData(), queryRequest.getRequestedFields())); } catch (LdapException | BaseException e) { LOGGER.error("Query Execution failed for Endpoint: " + host, e); result.get(result.size() - 1).addStatus(host, new Oops(e)); if (!Utils.isEmpty(endpoint.getSecondaryHost())) { result.get(result.size() - 1).addStatus(endpoint.getSecondaryHost(), new Oops(e)); } endpoint.setDestinationType(DestinationType.NONE); } LOGGER.debug(result.size() + " results found for: " + host); } response.addPartitionResponse(result); return response; } QueryRequestNonPagedExecutor(QueryRequest queryRequest); }
QueryRequestNonPagedExecutor extends QueryRequestExecutor { @Override QueryResponse execute() { QueryResponse response = new QueryResponse(); List<PartitionResponse> result = new ArrayList<>(); for (Endpoint endpoint : queryRequest.getEndpoints()) { String host = endpoint.getHost(); try { LOGGER.debug("Executing request for: " + host); PartitionResponse partitionResponse = new PartitionResponse(); result.add(partitionResponse); partitionResponse.setEndpoint(endpoint); LdapConnectionResult ldapConnectionResult = driverGetInstance().connect(endpoint); String baseSearchPath = tryResolveBasePath(ldapConnectionResult.getConnection(), endpoint.getBaseSearchPath()); endpoint.setBaseSearchPath(baseSearchPath); endpoint.setDestinationType(ldapConnectionResult.getDestinationType()); endpoint.setBaseSearchPath(baseSearchPath); partitionResponse.setStatus(ldapConnectionResult.getStatuses()); RoundtripResult roundtripResult = query(ldapConnectionResult.getConnection(), baseSearchPath); if (roundtripResult != null && roundtripResult.getData() != null) partitionResponse.setData(parserGetInstance().toEntityResponse(roundtripResult.getData(), queryRequest.getRequestedFields())); } catch (LdapException | BaseException e) { LOGGER.error("Query Execution failed for Endpoint: " + host, e); result.get(result.size() - 1).addStatus(host, new Oops(e)); if (!Utils.isEmpty(endpoint.getSecondaryHost())) { result.get(result.size() - 1).addStatus(endpoint.getSecondaryHost(), new Oops(e)); } endpoint.setDestinationType(DestinationType.NONE); } LOGGER.debug(result.size() + " results found for: " + host); } response.addPartitionResponse(result); return response; } QueryRequestNonPagedExecutor(QueryRequest queryRequest);  }
QueryRequestNonPagedExecutor extends QueryRequestExecutor { @Override QueryResponse execute() { QueryResponse response = new QueryResponse(); List<PartitionResponse> result = new ArrayList<>(); for (Endpoint endpoint : queryRequest.getEndpoints()) { String host = endpoint.getHost(); try { LOGGER.debug("Executing request for: " + host); PartitionResponse partitionResponse = new PartitionResponse(); result.add(partitionResponse); partitionResponse.setEndpoint(endpoint); LdapConnectionResult ldapConnectionResult = driverGetInstance().connect(endpoint); String baseSearchPath = tryResolveBasePath(ldapConnectionResult.getConnection(), endpoint.getBaseSearchPath()); endpoint.setBaseSearchPath(baseSearchPath); endpoint.setDestinationType(ldapConnectionResult.getDestinationType()); endpoint.setBaseSearchPath(baseSearchPath); partitionResponse.setStatus(ldapConnectionResult.getStatuses()); RoundtripResult roundtripResult = query(ldapConnectionResult.getConnection(), baseSearchPath); if (roundtripResult != null && roundtripResult.getData() != null) partitionResponse.setData(parserGetInstance().toEntityResponse(roundtripResult.getData(), queryRequest.getRequestedFields())); } catch (LdapException | BaseException e) { LOGGER.error("Query Execution failed for Endpoint: " + host, e); result.get(result.size() - 1).addStatus(host, new Oops(e)); if (!Utils.isEmpty(endpoint.getSecondaryHost())) { result.get(result.size() - 1).addStatus(endpoint.getSecondaryHost(), new Oops(e)); } endpoint.setDestinationType(DestinationType.NONE); } LOGGER.debug(result.size() + " results found for: " + host); } response.addPartitionResponse(result); return response; } QueryRequestNonPagedExecutor(QueryRequest queryRequest);   }