@Test public void testFindOne() { User user = new User(); when(userRepository.findOne(100)).thenReturn(user); User result = userService.findOne(100); assertThat(result, is(user)); }
@Test public void testFindByNameLike() { Pageable pageable = new PageRequest(1, 10); Page<User> page = new PageImpl<User>(Arrays.asList(new User())); when(userRepository.findByNameLike("foo", pageable)).thenReturn(page); Page<User> result = userService.findByNameLike("foo", pageable); assertThat(result, is(page)); }