@Test void run_WillCreateAdminUser_WhenAdminUserNotPresentInUsersProjection() { adminProvisionTask.run(); verify(usersRepository).save( new PersistableUser(ADMIN_ID, null, ADMIN_USERNAME, ENCODED_PASSWORD, ADMIN_DISPLAY_NAME, false, EnumSet.of(ADMIN), Instant.now(clock))); }
@PostConstruct public void run() { Optional<PersistableUser> adminUser = usersRepository.findByUsernameIgnoreCase(adminUsername); if (adminUser.isPresent()) { LOGGER.info("Skipping provisioning of admin account since it already exists"); return; } LOGGER.info("Provisioning admin user"); usersRepository.save(new PersistableUser(ADMIN_ID, null, adminUsername, passwordEncoder.encode(adminPassword), ADMIN_DISPLAY_NAME, false, EnumSet.of(ADMIN), Instant.now(clock))); }
AdminProvisionTask implements ReplayCompletionAware { @PostConstruct public void run() { Optional<PersistableUser> adminUser = usersRepository.findByUsernameIgnoreCase(adminUsername); if (adminUser.isPresent()) { LOGGER.info("Skipping provisioning of admin account since it already exists"); return; } LOGGER.info("Provisioning admin user"); usersRepository.save(new PersistableUser(ADMIN_ID, null, adminUsername, passwordEncoder.encode(adminPassword), ADMIN_DISPLAY_NAME, false, EnumSet.of(ADMIN), Instant.now(clock))); } }
AdminProvisionTask implements ReplayCompletionAware { @PostConstruct public void run() { Optional<PersistableUser> adminUser = usersRepository.findByUsernameIgnoreCase(adminUsername); if (adminUser.isPresent()) { LOGGER.info("Skipping provisioning of admin account since it already exists"); return; } LOGGER.info("Provisioning admin user"); usersRepository.save(new PersistableUser(ADMIN_ID, null, adminUsername, passwordEncoder.encode(adminPassword), ADMIN_DISPLAY_NAME, false, EnumSet.of(ADMIN), Instant.now(clock))); } AdminProvisionTask(Clock clock,
                              UsersRepository usersRepository,
                              PasswordEncoder passwordEncoder,
                              @Value("${application.setup.admin.username}") String adminUsername,
                              @Value("${application.setup.admin.password}") String adminPassword); }
AdminProvisionTask implements ReplayCompletionAware { @PostConstruct public void run() { Optional<PersistableUser> adminUser = usersRepository.findByUsernameIgnoreCase(adminUsername); if (adminUser.isPresent()) { LOGGER.info("Skipping provisioning of admin account since it already exists"); return; } LOGGER.info("Provisioning admin user"); usersRepository.save(new PersistableUser(ADMIN_ID, null, adminUsername, passwordEncoder.encode(adminPassword), ADMIN_DISPLAY_NAME, false, EnumSet.of(ADMIN), Instant.now(clock))); } AdminProvisionTask(Clock clock,
                              UsersRepository usersRepository,
                              PasswordEncoder passwordEncoder,
                              @Value("${application.setup.admin.username}") String adminUsername,
                              @Value("${application.setup.admin.password}") String adminPassword); @PostConstruct void run(); @Override void replayCompleted(); }
AdminProvisionTask implements ReplayCompletionAware { @PostConstruct public void run() { Optional<PersistableUser> adminUser = usersRepository.findByUsernameIgnoreCase(adminUsername); if (adminUser.isPresent()) { LOGGER.info("Skipping provisioning of admin account since it already exists"); return; } LOGGER.info("Provisioning admin user"); usersRepository.save(new PersistableUser(ADMIN_ID, null, adminUsername, passwordEncoder.encode(adminPassword), ADMIN_DISPLAY_NAME, false, EnumSet.of(ADMIN), Instant.now(clock))); } AdminProvisionTask(Clock clock,
                              UsersRepository usersRepository,
                              PasswordEncoder passwordEncoder,
                              @Value("${application.setup.admin.username}") String adminUsername,
                              @Value("${application.setup.admin.password}") String adminPassword); @PostConstruct void run(); @Override void replayCompleted();  }