@Test public void testFindNotActivatedUsersByCreationDateBefore() { userService.removeNotActivatedUsers(); DateTime now = new DateTime(); List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3)); assertThat(users).isEmpty(); }
@Test public void testRemoveOldPersistentTokens() { User admin = userRepository.findOneByLogin("admin"); int existingCount = persistentTokenRepository.findByUser(admin).size(); generateUserToken(admin, "1111-1111", new LocalDate()); LocalDate now = new LocalDate(); generateUserToken(admin, "2222-2222", now.minusDays(32)); assertThat(persistentTokenRepository.findByUser(admin)).hasSize(existingCount + 2); userService.removeOldPersistentTokens(); assertThat(persistentTokenRepository.findByUser(admin)).hasSize(existingCount + 1); }