@Test public void createViaEmail() { Account account = service.createViaEmail("myname", "foo@gmail.com", "pwd123", lc); Account loaded = accountDao.findById(account.getAccountId()).get(); assertEquals(account, loaded); assertEquals("foo@gmail.com", loaded.getEmail()); assertFalse(loaded.isActivated()); assertEquals(EnumSet.of(Authority.TOURIST), loaded.getAuthorities()); verify(mockMailAgent).sendAccountActivation(eq(lc), eq(account), Mockito.matches("[a-z\\-0-9]{36}")); AccountOnceToken token = accountDao.listOnceTokens().get(0); assertEquals(account.getAccountId(), token.getAccountId()); assertEquals(AccountOnceToken.Type.ACTIVATION, token.getTokenType()); assertFalse(token.isExpired(Instant.now().plus(Duration.ofHours(23)))); assertFalse(token.isComplete()); AccountStats stats = service.loadAccountStats(account.getUsername()); assertEquals(AccountStats.zero(account.getAccountId()), stats); }
@Override public Account createViaEmail(String username, String email, String password, Locale locale) { Preconditions.checkArgument(Account.isValidPassword(password)); Preconditions.checkArgument(Account.isValidUsername(username)); Preconditions.checkNotNull(email); Instant now = Instant.now(clock); Account account = accountDao.create(username, email, passwordEncoder.encode(password), now); sendOnceAccountActivation(account, locale, now); return account; }
AccountServiceImpl implements AccountService { @Override public Account createViaEmail(String username, String email, String password, Locale locale) { Preconditions.checkArgument(Account.isValidPassword(password)); Preconditions.checkArgument(Account.isValidUsername(username)); Preconditions.checkNotNull(email); Instant now = Instant.now(clock); Account account = accountDao.create(username, email, passwordEncoder.encode(password), now); sendOnceAccountActivation(account, locale, now); return account; } }
AccountServiceImpl implements AccountService { @Override public Account createViaEmail(String username, String email, String password, Locale locale) { Preconditions.checkArgument(Account.isValidPassword(password)); Preconditions.checkArgument(Account.isValidUsername(username)); Preconditions.checkNotNull(email); Instant now = Instant.now(clock); Account account = accountDao.create(username, email, passwordEncoder.encode(password), now); sendOnceAccountActivation(account, locale, now); return account; }  }
AccountServiceImpl implements AccountService { @Override public Account createViaEmail(String username, String email, String password, Locale locale) { Preconditions.checkArgument(Account.isValidPassword(password)); Preconditions.checkArgument(Account.isValidUsername(username)); Preconditions.checkNotNull(email); Instant now = Instant.now(clock); Account account = accountDao.create(username, email, passwordEncoder.encode(password), now); sendOnceAccountActivation(account, locale, now); return account; }  @Override Account createViaEmail(String username, String email, String password, Locale locale); @Override Optional<Account> findMe(Authorization authorization); @Override Optional<AccountAuth> authenticate(String username, String password); @Override Optional<AccountAccessToken> strongVerifyAccessToken(String rawAccessToken); @Override AccountAuth extendsAccessToken(AccountAccessToken accessToken); @Override boolean isUsernameAvailable(String username); @Override boolean isEmailAvailable(String email); @Override void updateAuthorities(Authorization authorization, EnumSet<Authority> authorities); @Override boolean activate(String inputOnceToken); @Override void resendActivation(Authorization authorization, Locale locale); @Override void sendResetPassword(String username, String email, Locale locale); @Override Optional<AccountOnceToken> findValidResetPasswordToken(String inputOnceToken); @Override void updatePasswordWithOnceToken(String accountOnceToken, String password, Locale locale); @Override AccountAuth updateNewPassword(Authorization authorization,
      String oldPassword,
      String newPassword,
      Locale locale); @Override Optional<AccountAccessToken> tryDecodeAccessToken(String rawAccountAccessToken); @Override AccountStats loadAccountStats(String username); @Override Account loadAccount(String username); @Override String updateDescription(Authorization authorization, String description); @Override String loadEditableDescription(Authorization authorization); @Override void complaintEmail(List<String> emails); @Override void muteEmail(List<String> emails); @Override AccountOnceToken createOauthDirectAuthorizeToken(Authorization authorization); @Override Optional<Account> oauthDirectAuthorize(String inputOnceToken); }
AccountServiceImpl implements AccountService { @Override public Account createViaEmail(String username, String email, String password, Locale locale) { Preconditions.checkArgument(Account.isValidPassword(password)); Preconditions.checkArgument(Account.isValidUsername(username)); Preconditions.checkNotNull(email); Instant now = Instant.now(clock); Account account = accountDao.create(username, email, passwordEncoder.encode(password), now); sendOnceAccountActivation(account, locale, now); return account; }  @Override Account createViaEmail(String username, String email, String password, Locale locale); @Override Optional<Account> findMe(Authorization authorization); @Override Optional<AccountAuth> authenticate(String username, String password); @Override Optional<AccountAccessToken> strongVerifyAccessToken(String rawAccessToken); @Override AccountAuth extendsAccessToken(AccountAccessToken accessToken); @Override boolean isUsernameAvailable(String username); @Override boolean isEmailAvailable(String email); @Override void updateAuthorities(Authorization authorization, EnumSet<Authority> authorities); @Override boolean activate(String inputOnceToken); @Override void resendActivation(Authorization authorization, Locale locale); @Override void sendResetPassword(String username, String email, Locale locale); @Override Optional<AccountOnceToken> findValidResetPasswordToken(String inputOnceToken); @Override void updatePasswordWithOnceToken(String accountOnceToken, String password, Locale locale); @Override AccountAuth updateNewPassword(Authorization authorization,
      String oldPassword,
      String newPassword,
      Locale locale); @Override Optional<AccountAccessToken> tryDecodeAccessToken(String rawAccountAccessToken); @Override AccountStats loadAccountStats(String username); @Override Account loadAccount(String username); @Override String updateDescription(Authorization authorization, String description); @Override String loadEditableDescription(Authorization authorization); @Override void complaintEmail(List<String> emails); @Override void muteEmail(List<String> emails); @Override AccountOnceToken createOauthDirectAuthorizeToken(Authorization authorization); @Override Optional<Account> oauthDirectAuthorize(String inputOnceToken);  }