UserService { public User createUserWithRole(String username, String password, Role role, String givenName, String surname, String commonName, boolean partiallyCreated) { logger.debug("Creating user entry for: {}", username); Preconditions.checkNotNull(password, "password must not be null"); Preconditions.checkState(!password.isEmpty(), "password must not be empty"); User user = new User(); user.setEnabled(true); user.setUsername(username); return saveUserWithRole(user, password, role, givenName, surname, commonName, partiallyCreated); }  User createUserWithRole(String username, String password, Role role, String givenName, String surname, String commonName, boolean partiallyCreated); @Transactional User saveUserWithRole(User user, String password, Role role, String givenName, String surname, String commonName, boolean partiallyCreated); User createUserWithRole(String username, String password, Role role); String createAuthorityName(Role role); User findSystemUser(); @Transactional void updateCreatedByUserToSystemUser(User userToUpdate); @Transactional void deleteUser(User user); User createBasicUser(String username, String givenName, String surname, String commonName, boolean partiallyCreated); User createOrUpdateBasicUser(User user, String username, String givenName, String surname, String commonName); User getOrCreatePartialBasicUser(String username); User getOrCreateOrUpdateBasicUser(String username, String givenName, String surname, String commonName); static final String SYSTEM_USERNAME; }
@Test(expected = IllegalStateException.class) public void testCreateUserWithEmptyPassword() { String username = "testUser"; String pwd = ""; userService.createUserWithRole(username, pwd, Role.USER); }
@Test(expected = NullPointerException.class) public void testCreateUserWithNullPassword() { String username = "testUser"; String pwd = null; userService.createUserWithRole(username, pwd, Role.USER); }