@Test public void syncUser() { testSubject.syncUser(new User("Demo", "TEST")); assertEquals("TEST", users.get(0).getPassword()); }
private User syncUser(String username, String password, Set<UserRole> roles) { synchronized (userRepository) { if (StringUtils.isEmpty(password)) { password = getPassword(username); } User user = userRepository.save(new User(username, password, roles)); userRepository.flush(); return user; } }
UserController { private User syncUser(String username, String password, Set<UserRole> roles) { synchronized (userRepository) { if (StringUtils.isEmpty(password)) { password = getPassword(username); } User user = userRepository.save(new User(username, password, roles)); userRepository.flush(); return user; } } }
UserController { private User syncUser(String username, String password, Set<UserRole> roles) { synchronized (userRepository) { if (StringUtils.isEmpty(password)) { password = getPassword(username); } User user = userRepository.save(new User(username, password, roles)); userRepository.flush(); return user; } } UserController(PasswordEncoder passwordEncoder, UserRepository userRepository); }
UserController { private User syncUser(String username, String password, Set<UserRole> roles) { synchronized (userRepository) { if (StringUtils.isEmpty(password)) { password = getPassword(username); } User user = userRepository.save(new User(username, password, roles)); userRepository.flush(); return user; } } UserController(PasswordEncoder passwordEncoder, UserRepository userRepository); @Transactional void deleteUser(String username); List<User> getUsers(); @Transactional User updateUser(String username, String password, Set<UserRole> roles); @Transactional void syncUser(User jpaUser); String getPassword(String userName); User findUser(String name); @Transactional void removeRolesForContext(String context); @Transactional void deleteAll(); }
UserController { private User syncUser(String username, String password, Set<UserRole> roles) { synchronized (userRepository) { if (StringUtils.isEmpty(password)) { password = getPassword(username); } User user = userRepository.save(new User(username, password, roles)); userRepository.flush(); return user; } } UserController(PasswordEncoder passwordEncoder, UserRepository userRepository); @Transactional void deleteUser(String username); List<User> getUsers(); @Transactional User updateUser(String username, String password, Set<UserRole> roles); @Transactional void syncUser(User jpaUser); String getPassword(String userName); User findUser(String name); @Transactional void removeRolesForContext(String context); @Transactional void deleteAll();  }