@Test public void testFindAllUserReturnsAListOfUserViews() { UserView testView = buildTestView(); when(userViewRepository.findAll(any(Pageable.class))).thenReturn(new PageImpl<>(Collections.singletonList(testView))); List<UserView> result = testSubject.findAll(new FindAllUsersQuery(0, 50)); assertEquals(testView, result.get(0)); }
@QueryHandler public List<UserView> findAll(FindAllUsersQuery query) { return userRepository.findAll(PageRequest.of(query.getPageOffset(), query.getPageSize(), Sort.by(asc("name")))) .getContent(); }
UserEventHandler { @QueryHandler public List<UserView> findAll(FindAllUsersQuery query) { return userRepository.findAll(PageRequest.of(query.getPageOffset(), query.getPageSize(), Sort.by(asc("name")))) .getContent(); } }
UserEventHandler { @QueryHandler public List<UserView> findAll(FindAllUsersQuery query) { return userRepository.findAll(PageRequest.of(query.getPageOffset(), query.getPageSize(), Sort.by(asc("name")))) .getContent(); } UserEventHandler(UserViewRepository userRepository); }
UserEventHandler { @QueryHandler public List<UserView> findAll(FindAllUsersQuery query) { return userRepository.findAll(PageRequest.of(query.getPageOffset(), query.getPageSize(), Sort.by(asc("name")))) .getContent(); } UserEventHandler(UserViewRepository userRepository); @EventHandler void on(UserCreatedEvent event); @QueryHandler UserView find(UserByIdQuery query); @QueryHandler List<UserView> findAll(FindAllUsersQuery query); }
UserEventHandler { @QueryHandler public List<UserView> findAll(FindAllUsersQuery query) { return userRepository.findAll(PageRequest.of(query.getPageOffset(), query.getPageSize(), Sort.by(asc("name")))) .getContent(); } UserEventHandler(UserViewRepository userRepository); @EventHandler void on(UserCreatedEvent event); @QueryHandler UserView find(UserByIdQuery query); @QueryHandler List<UserView> findAll(FindAllUsersQuery query);  }