@Test public final void canCreateNewAccount() { Account account = new Account(); given(accountDAO.persist(accountCaptor.capture())).willReturn(account); AccountDto accountDto = new AccountDto(null, "joe", "joe@example.com", AccountType.Normal, Sets.newHashSet(Role.admin)); String password = "password"; String username = "user"; service.registerNewAccount(accountDto, username, password.toCharArray()); Account accountCaptured = accountCaptor.getValue(); assertThat(accountCaptured.getUsername()).isEqualTo("user"); assertThat(accountCaptured.getPasswordHash()).startsWith((CharSequence)"$31$16"); }
@Transactional public AccountDto registerNewAccount(AccountDto accountDto, String username, char[] password) { String passwordHash = passwordUtil.hash(password); Account account = new Account(accountDto.getName(), accountDto.getEmail(), username, passwordHash, accountDto.getAccountType(), accountDto.getRoles()); account = accountDAO.persist(account); accountDto.setId(account.getId()); return accountDto; }
AccountService implements Serializable { @Transactional public AccountDto registerNewAccount(AccountDto accountDto, String username, char[] password) { String passwordHash = passwordUtil.hash(password); Account account = new Account(accountDto.getName(), accountDto.getEmail(), username, passwordHash, accountDto.getAccountType(), accountDto.getRoles()); account = accountDAO.persist(account); accountDto.setId(account.getId()); return accountDto; } }
AccountService implements Serializable { @Transactional public AccountDto registerNewAccount(AccountDto accountDto, String username, char[] password) { String passwordHash = passwordUtil.hash(password); Account account = new Account(accountDto.getName(), accountDto.getEmail(), username, passwordHash, accountDto.getAccountType(), accountDto.getRoles()); account = accountDAO.persist(account); accountDto.setId(account.getId()); return accountDto; } @Inject  AccountService(AccountDAO accountDAO); @SuppressWarnings("unused")  AccountService(); }
AccountService implements Serializable { @Transactional public AccountDto registerNewAccount(AccountDto accountDto, String username, char[] password) { String passwordHash = passwordUtil.hash(password); Account account = new Account(accountDto.getName(), accountDto.getEmail(), username, passwordHash, accountDto.getAccountType(), accountDto.getRoles()); account = accountDAO.persist(account); accountDto.setId(account.getId()); return accountDto; } @Inject  AccountService(AccountDAO accountDAO); @SuppressWarnings("unused")  AccountService(); @Transactional AccountDto registerNewAccount(AccountDto accountDto, String username,
            char[] password); Optional<Account> authenticate(String username, String password); List<AccountDto> getAllAccounts(boolean showDisabled); @Transactional boolean updateAccount(AccountDto accountDto); }
AccountService implements Serializable { @Transactional public AccountDto registerNewAccount(AccountDto accountDto, String username, char[] password) { String passwordHash = passwordUtil.hash(password); Account account = new Account(accountDto.getName(), accountDto.getEmail(), username, passwordHash, accountDto.getAccountType(), accountDto.getRoles()); account = accountDAO.persist(account); accountDto.setId(account.getId()); return accountDto; } @Inject  AccountService(AccountDAO accountDAO); @SuppressWarnings("unused")  AccountService(); @Transactional AccountDto registerNewAccount(AccountDto accountDto, String username,
            char[] password); Optional<Account> authenticate(String username, String password); List<AccountDto> getAllAccounts(boolean showDisabled); @Transactional boolean updateAccount(AccountDto accountDto);  }