UserService { @Scheduled(cron = "0 0 1 * * ?") public void removeNotActivatedUsers() { DateTime now = new DateTime(); List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3)); for (User user : users) { log.debug("Deleting not activated user {}", user.getLogin()); userRepository.delete(user); } }  Optional<User> activateRegistration(String key); Optional<User> completePasswordReset(String newPassword, String key); Optional<User> requestPasswordReset(String mail); User createUserInformation(String login, String password, String firstName, String lastName, String email,
                                      String langKey); void updateUserInformation(String firstName, String lastName, String email, String langKey); void changePassword(String password); @Transactional(readOnly = true) User getUserWithAuthorities(); @Scheduled(cron = "0 0 0 * * ?") void removeOldPersistentTokens(); @Scheduled(cron = "0 0 1 * * ?") void removeNotActivatedUsers();  }
@Test public void testFindNotActivatedUsersByCreationDateBefore() { userService.removeNotActivatedUsers(); DateTime now = new DateTime(); List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3)); assertThat(users).isEmpty(); }