@Test public void testFindPerson() throws IllegalAccessException, InvocationTargetException { LdapOperations ldapOperations = Mockito.mock(LdapOperations.class); LdapClientImpl ldapClient = new LdapClientImpl(); ldapClient.setEngineBlock(new EngineBlockImpl()); ldapClient.setLdapOperations(ldapOperations); Mockito.when(ldapOperations.search(Mockito.anyString(), Mockito.anyString(), (AttributesMapper) Mockito.any())) .thenReturn(Collections.EMPTY_LIST); Person findPerson = ldapClient.findPerson("urn:collab:person:myuniversity:john.doe"); assertNull(findPerson); }
@Override @SuppressWarnings("unchecked") public Person findPerson(String identifier) { Filter query = getFilter(identifier); List<Person> search = findPersons(query); if (CollectionUtils.isEmpty(search)) { return null; } if (search.size() > 1) { throw new RuntimeException("Found more then one LDAP entry for identifier(" + query.toString() + ")"); } return search.get(0); }
LdapClientImpl implements LdapClient { @Override @SuppressWarnings("unchecked") public Person findPerson(String identifier) { Filter query = getFilter(identifier); List<Person> search = findPersons(query); if (CollectionUtils.isEmpty(search)) { return null; } if (search.size() > 1) { throw new RuntimeException("Found more then one LDAP entry for identifier(" + query.toString() + ")"); } return search.get(0); } }
LdapClientImpl implements LdapClient { @Override @SuppressWarnings("unchecked") public Person findPerson(String identifier) { Filter query = getFilter(identifier); List<Person> search = findPersons(query); if (CollectionUtils.isEmpty(search)) { return null; } if (search.size() > 1) { throw new RuntimeException("Found more then one LDAP entry for identifier(" + query.toString() + ")"); } return search.get(0); }  }
LdapClientImpl implements LdapClient { @Override @SuppressWarnings("unchecked") public Person findPerson(String identifier) { Filter query = getFilter(identifier); List<Person> search = findPersons(query); if (CollectionUtils.isEmpty(search)) { return null; } if (search.size() > 1) { throw new RuntimeException("Found more then one LDAP entry for identifier(" + query.toString() + ")"); } return search.get(0); }  @Override @SuppressWarnings("unchecked") Person findPerson(String identifier); @Override List<Person> findPersons(Collection<String> identifiers); void setLdapOperations(LdapOperations ldapOperations); void setEngineBlock(EngineBlock engineBlock); }
LdapClientImpl implements LdapClient { @Override @SuppressWarnings("unchecked") public Person findPerson(String identifier) { Filter query = getFilter(identifier); List<Person> search = findPersons(query); if (CollectionUtils.isEmpty(search)) { return null; } if (search.size() > 1) { throw new RuntimeException("Found more then one LDAP entry for identifier(" + query.toString() + ")"); } return search.get(0); }  @Override @SuppressWarnings("unchecked") Person findPerson(String identifier); @Override List<Person> findPersons(Collection<String> identifiers); void setLdapOperations(LdapOperations ldapOperations); void setEngineBlock(EngineBlock engineBlock);  }