@Test public void findChangedUsersPaged_searchFiltersTest() throws Exception { List<LdapUser> pageOne = new ArrayList<>(); pageOne.add(buildUser("axlrose")); pageOne.add(buildUser("kurtcobain")); pageOne.add(buildUser("plesh")); List<LdapUser> pageTwo = new ArrayList<>(); pageTwo.add(buildUser("plesh")); pageTwo.add(buildUser("bkreutzmann")); pageTwo.add(buildUser("davidgilmour")); syncConfig.setSyncPageSize(3); Capture<String> allChangedUsersPageFilter1 = Capture.newInstance(); Capture<String> allChangedUsersPageFilter2 = Capture.newInstance(); Capture<String> allChangedUsersFilter = Capture.newInstance(); expect(mockLdapTemplate.search( eq(syncConfig.getUserSearchBase()), capture(allChangedUsersFilter), anyObject(SearchControls.class), anyObject(AcmUserContextMapper.class), anyObject(AggregateDirContextProcessor.class))).andReturn(pageOne); expect(mockLdapTemplate.search( eq(syncConfig.getUserSearchBase()), capture(allChangedUsersPageFilter1), anyObject(SearchControls.class), anyObject(AcmUserContextMapper.class), anyObject(AggregateDirContextProcessor.class))).andReturn(pageTwo); expect(mockLdapTemplate.search( eq(syncConfig.getUserSearchBase()), capture(allChangedUsersPageFilter2), anyObject(SearchControls.class), anyObject(AcmUserContextMapper.class), anyObject(AggregateDirContextProcessor.class))).andReturn(new ArrayList<>()); replayAll(); String ldapLastSyncDateTimestamp = ZonedDateTime.now(ZoneOffset.UTC).minusDays(1).toString(); List<LdapUser> found = unit.findUsersPaged(mockLdapTemplate, syncConfig, Optional.of(ldapLastSyncDateTimestamp)); verifyAll(); assertEquals(pageOne.size() + pageTwo.size() - 1, found.size()); String actualChangedGroupsFilter = allChangedUsersFilter.getValue(); String actualChangedGroupsPageFilter1 = allChangedUsersPageFilter1.getValue(); String actualChangedGroupsPageFilter2 = allChangedUsersPageFilter2.getValue(); ldapLastSyncDateTimestamp = Directory.valueOf(syncConfig.getDirectoryType()) .convertToDirectorySpecificTimestamp(ldapLastSyncDateTimestamp); String expectedChangedGroupsFilter = String.format(syncConfig.getAllChangedUsersFilter(), ldapLastSyncDateTimestamp); String expectedChangedGroupsPageFilter1 = String.format(syncConfig.getAllChangedUsersPageFilter(), "plesh", ldapLastSyncDateTimestamp); String expectedChangedGroupsPageFilter2 = String.format(syncConfig.getAllChangedUsersPageFilter(), "davidgilmour", ldapLastSyncDateTimestamp); assertEquals(expectedChangedGroupsFilter, actualChangedGroupsFilter); assertEquals(expectedChangedGroupsPageFilter1, actualChangedGroupsPageFilter1); assertEquals(expectedChangedGroupsPageFilter2, actualChangedGroupsPageFilter2); }
@Override public List<LdapUser> findUsersPaged(LdapTemplate template, AcmLdapSyncConfig syncConfig, Optional<String> ldapLastSyncDate) { return findUsers(template, syncConfig, syncConfig.getUserSyncAttributes(), ldapLastSyncDate); }
CustomPagedLdapDao implements SpringLdapDao { @Override public List<LdapUser> findUsersPaged(LdapTemplate template, AcmLdapSyncConfig syncConfig, Optional<String> ldapLastSyncDate) { return findUsers(template, syncConfig, syncConfig.getUserSyncAttributes(), ldapLastSyncDate); } }
CustomPagedLdapDao implements SpringLdapDao { @Override public List<LdapUser> findUsersPaged(LdapTemplate template, AcmLdapSyncConfig syncConfig, Optional<String> ldapLastSyncDate) { return findUsers(template, syncConfig, syncConfig.getUserSyncAttributes(), ldapLastSyncDate); }  }
CustomPagedLdapDao implements SpringLdapDao { @Override public List<LdapUser> findUsersPaged(LdapTemplate template, AcmLdapSyncConfig syncConfig, Optional<String> ldapLastSyncDate) { return findUsers(template, syncConfig, syncConfig.getUserSyncAttributes(), ldapLastSyncDate); }  @Override List<LdapUser> findUsersPaged(LdapTemplate template, AcmLdapSyncConfig syncConfig, Optional<String> ldapLastSyncDate); List<LdapUser> findUsers(LdapTemplate template, AcmLdapSyncConfig syncConfig,
            String[] attributes, Optional<String> ldapLastSyncDate); @Override List<LdapGroup> findGroupsPaged(LdapTemplate template, AcmLdapSyncConfig config, Optional<String> ldapLastSyncDate); }
CustomPagedLdapDao implements SpringLdapDao { @Override public List<LdapUser> findUsersPaged(LdapTemplate template, AcmLdapSyncConfig syncConfig, Optional<String> ldapLastSyncDate) { return findUsers(template, syncConfig, syncConfig.getUserSyncAttributes(), ldapLastSyncDate); }  @Override List<LdapUser> findUsersPaged(LdapTemplate template, AcmLdapSyncConfig syncConfig, Optional<String> ldapLastSyncDate); List<LdapUser> findUsers(LdapTemplate template, AcmLdapSyncConfig syncConfig,
            String[] attributes, Optional<String> ldapLastSyncDate); @Override List<LdapGroup> findGroupsPaged(LdapTemplate template, AcmLdapSyncConfig config, Optional<String> ldapLastSyncDate);  }