### Question:
UserEventHandler { @QueryHandler public UserView find(UserByIdQuery query) { String userId = query.getUserId().getIdentifier(); return Optional.ofNullable(userRepository.findByIdentifier(userId)) .orElseGet(() -> { logger.warn("Tried to retrieve a User query model with a non existent user id [{}]", userId); return null; }); } UserEventHandler(UserViewRepository userRepository); @EventHandler void on(UserCreatedEvent event); @QueryHandler UserView find(UserByIdQuery query); @QueryHandler List<UserView> findAll(FindAllUsersQuery query);  }### Answer:
@Test public void testFindUserByIdReturnsAUserView() { UserView testView = buildTestView(); when(userViewRepository.findByIdentifier(testUserId.getIdentifier())).thenReturn(testView); UserView result = testSubject.find(new UserByIdQuery(testUserId)); assertEquals(testView, result); }
@Test public void testFindUserByIdReturnsNullForNonExistingUserId() { when(userViewRepository.findByIdentifier(testUserId.getIdentifier())).thenReturn(null); assertNull(testSubject.find(new UserByIdQuery(testUserId))); }