@Test
public void testReferralMethod() {

  final Configuration configuration = createNiceMock(Configuration.class);
  final Users users = createNiceMock(Users.class);
  LdapContextSource ldapContextSource = createNiceMock(LdapContextSource.class);
  List<String> ldapUrls = Collections.singletonList("url");
  LdapTemplate ldapTemplate = createNiceMock(LdapTemplate.class);
  LdapServerProperties ldapServerProperties = createNiceMock(LdapServerProperties.class);
  expect(configuration.getLdapServerProperties()).andReturn(ldapServerProperties).anyTimes();
  expect(ldapServerProperties.getLdapUrls()).andReturn(ldapUrls).anyTimes();
  expect(ldapServerProperties.getReferralMethod()).andReturn("follow");
  ldapContextSource.setReferral("follow");
  ldapTemplate.setIgnorePartialResultException(true);
  replay(ldapTemplate, configuration, ldapServerProperties, ldapContextSource);
  final TestAmbariLdapDataPopulator populator = new TestAmbariLdapDataPopulator(configuration, users);
  populator.setLdapContextSource(ldapContextSource);
  populator.setLdapTemplate(ldapTemplate);
  populator.setLdapServerProperties(ldapServerProperties);
  populator.loadLdapTemplate();
  verify(ldapTemplate, configuration, ldapServerProperties, ldapContextSource);
}