October 2018
Intermediate to advanced
590 pages
15h 5m
English
With all of the test methods we created in the preceding section, you probably already have an idea of how RegistrationManagement will look, and here it is:
...@Componentpublic class RegistrationService { private UserRepository repository; private PasswordEncryptor passwordEncryptor; public RegistrationManagement(UserRepository repository, PasswordEncryptor passwordEncryptor) { this.repository = repository; this.passwordEncryptor = passwordEncryptor; } public User register(String username, String emailAddress, String password) throws RegistrationException { User existingUser = repository.findByUsername(username); if (existingUser != null) { throw new UsernameExistsException(); } existingUser = Read now
Unlock full access