@Test public void findByName() { List<User> users = Lists.newArrayList(); users.add(new User()); when(userRepository.findAll(any(BooleanExpression.class))).thenReturn(users); userService.findByName("need4spd"); verify(userRepository, times(1)).findAll(any(BooleanExpression.class)); }
@Test public void findByUserManagerId() { @SuppressWarnings("unchecked") Page<User> requestedPage = mock(Page.class); when(userRepository.findByUserManagerId(any(Long.class), any(Pageable.class))) .thenReturn(requestedPage); userService.findByUserManagerId(0L, 0, 5); verify(userRepository, times(1)).findByUserManagerId(any(Long.class), any(Pageable.class)); }