@Test public void findUserByNameShouldReturnUserDtoWhenUserWasFound() { given(userRepository.findByUserName(USER_NAME)).willReturn(userEntity); UserDTO result = userService.findUserByName(USER_NAME); then(converterService).should().convert(userEntity, UserDTO.class); then(userRepository).should().findByUserName(USER_NAME); assertThat(result, is(detailedUserDTO)); }
@Transactional(readOnly = true) @Override public UserDTO findUserByName(String username) { Assert.notNull(username); UserEntity user = userRepository.findByUserName(username); return (user != null) ? converterService.convert(user, UserDTO.class) : null; }
UserServiceImpl implements UserService { @Transactional(readOnly = true) @Override public UserDTO findUserByName(String username) { Assert.notNull(username); UserEntity user = userRepository.findByUserName(username); return (user != null) ? converterService.convert(user, UserDTO.class) : null; } }
UserServiceImpl implements UserService { @Transactional(readOnly = true) @Override public UserDTO findUserByName(String username) { Assert.notNull(username); UserEntity user = userRepository.findByUserName(username); return (user != null) ? converterService.convert(user, UserDTO.class) : null; }  }
UserServiceImpl implements UserService { @Transactional(readOnly = true) @Override public UserDTO findUserByName(String username) { Assert.notNull(username); UserEntity user = userRepository.findByUserName(username); return (user != null) ? converterService.convert(user, UserDTO.class) : null; }  @Transactional(readOnly = true) UserDTO login(UserDTO user); @Transactional @Override Long saveOrUpdate(UserDTO userDTO); @Transactional(readOnly = true) @Override UserDTO findUserByName(String username); }
UserServiceImpl implements UserService { @Transactional(readOnly = true) @Override public UserDTO findUserByName(String username) { Assert.notNull(username); UserEntity user = userRepository.findByUserName(username); return (user != null) ? converterService.convert(user, UserDTO.class) : null; }  @Transactional(readOnly = true) UserDTO login(UserDTO user); @Transactional @Override Long saveOrUpdate(UserDTO userDTO); @Transactional(readOnly = true) @Override UserDTO findUserByName(String username);  }