@Test public void testOnUserCreatedEventAUserViewIsSaved() { testSubject.on(new UserCreatedEvent(testUserId, NAME, USERNAME, PASSWORD)); ArgumentCaptor<UserView> argumentCaptor = ArgumentCaptor.forClass(UserView.class); verify(userViewRepository).save(argumentCaptor.capture()); UserView result = argumentCaptor.getValue(); assertNotNull(result); assertEquals(testUserId.getIdentifier(), result.getIdentifier()); assertEquals(NAME, result.getName()); assertEquals(USERNAME, result.getUsername()); }
@EventHandler public void on(UserCreatedEvent event) { UserView userView = new UserView(); userView.setIdentifier(event.getUserId().getIdentifier()); userView.setName(event.getName()); userView.setUsername(event.getUsername()); userRepository.save(userView); }
UserEventHandler { @EventHandler public void on(UserCreatedEvent event) { UserView userView = new UserView(); userView.setIdentifier(event.getUserId().getIdentifier()); userView.setName(event.getName()); userView.setUsername(event.getUsername()); userRepository.save(userView); } }
UserEventHandler { @EventHandler public void on(UserCreatedEvent event) { UserView userView = new UserView(); userView.setIdentifier(event.getUserId().getIdentifier()); userView.setName(event.getName()); userView.setUsername(event.getUsername()); userRepository.save(userView); } UserEventHandler(UserViewRepository userRepository); }
UserEventHandler { @EventHandler public void on(UserCreatedEvent event) { UserView userView = new UserView(); userView.setIdentifier(event.getUserId().getIdentifier()); userView.setName(event.getName()); userView.setUsername(event.getUsername()); userRepository.save(userView); } UserEventHandler(UserViewRepository userRepository); @EventHandler void on(UserCreatedEvent event); @QueryHandler UserView find(UserByIdQuery query); @QueryHandler List<UserView> findAll(FindAllUsersQuery query); }
UserEventHandler { @EventHandler public void on(UserCreatedEvent event) { UserView userView = new UserView(); userView.setIdentifier(event.getUserId().getIdentifier()); userView.setName(event.getName()); userView.setUsername(event.getUsername()); userRepository.save(userView); } UserEventHandler(UserViewRepository userRepository); @EventHandler void on(UserCreatedEvent event); @QueryHandler UserView find(UserByIdQuery query); @QueryHandler List<UserView> findAll(FindAllUsersQuery query);  }