### Question:
UserListener { @EventHandler public void handleUpdateNotification(NotificationSettingsUpdatedEvent event) { UserEntry user = loadUser(event.getUserId(), event.getUsername()); if (user == null) { return; } user.setLogonAlert(event.isLogonAlert()); user.setExecutedAlert(event.isExecutedAlert()); user.setWithdrawMoneyAlert(event.isWithdrawMoneyAlert()); user.setWithdrawItemAlert(event.isWithdrawItemAlert()); userRepository.save(user); logger.info("user {} notification settings' been changed, id {}", event.getUsername(), event.getUserId()); }  @EventHandler void handleUserCreated(UserCreatedEvent event); @EventHandler void handleUserPasswordChanged(PasswordChangedEvent event); @EventHandler void handleUserWithdrawPasswordCreated(WithdrawPasswordCreatedEvent event); @EventHandler void handleUserWithdrawPasswordChanged(WithdrawPasswordChangedEvent event); @EventHandler void handleUserInfoChanged(UserInfoChangedEvent event); @EventHandler void handleUserAdminInfoChanged(UserAdminInfoChangedEvent event); @EventHandler void handleUpdateNotification(NotificationSettingsUpdatedEvent event); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setUserRepository(UserQueryRepository userRepository);  }### Answer:
@Test public void testHandleUpdateNotification() throws Exception { final UserId userId = new UserId(); final String username = "buyerAbc"; final UserQueryRepository repository = mock(UserQueryRepository.class); UserEntry user = new UserEntry(); when(repository.findOne(eq(userId.toString()))).thenReturn(user); final NotificationSettingsUpdatedEvent event = new NotificationSettingsUpdatedEvent(userId, username, false, true, true, false); final UserListener listener = new UserListener(); listener.setUserRepository(repository); listener.handleUpdateNotification(event); final ArgumentCaptor<UserEntry> captor = ArgumentCaptor.forClass(UserEntry.class); verify(repository).save(captor.capture()); final UserEntry userEntry = captor.getValue(); assertThat(userEntry, notNullValue()); assertThat(userEntry.isLogonAlert(), is(false)); assertThat(userEntry.isWithdrawMoneyAlert(), is(true)); assertThat(userEntry.isWithdrawItemAlert(), is(true)); assertThat(userEntry.isExecutedAlert(), is(false)); verify(repository).findOne(eq(userId.toString())); }