### Question:
UserCommandHandler { @CommandHandler public void handleUpdateNotificationCommand(UpdateNotificationSettingsCommand command) { notNull(command.getUserId(), "user Id cannot be null"); hasLength(command.getUserId().toString(), "user Id cannot be empty"); hasLength(command.getUsername(), "username cannot be null"); User user = repository.load(command.getUserId()); if (user == null) { logger.warn("cannot find user {}", command.getUserId()); return; } user.updateNotificationSettings( command.isLogonAlert(), command.isWithdrawMoneyAlert(), command.isWithdrawItemAlert(), command.isExecutedAlert()); logger.info("userid {}, username {} has updated notification info {}!", command.getUserId(), command.getUsername(), command); }  @CommandHandler UserId handleCreateUser(CreateUserCommand command); @CommandHandler UserAccount handleAuthenticateUser(AuthenticateUserCommand command); @CommandHandler String handleForgetPassword(ForgetPasswordCommand command); @CommandHandler String handlePasswordReset(ResetPasswordCommand command); @CommandHandler void handleChangePassword(ChangePasswordCommand command); @CommandHandler void handleChangeWithdrawPasswordCommand(ChangeWithdrawPasswordCommand command); @CommandHandler void handleCreateWithdrawPasswordCommand(CreateWithdrawPasswordCommand command); @CommandHandler void handleUpdateNotificationCommand(UpdateNotificationSettingsCommand command); @CommandHandler void handleChangeInfoCommand(ChangeInfoCommand command); @CommandHandler void handleChangeAdminInfoCommand(ChangeAdminInfoCommand command); @Autowired @Qualifier("userRepository") void setRepository(Repository<User> userRepository); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setPasswordEncoder(PasswordEncoder passwordEncoder); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setUserPasswordResetRepository(UserPasswordResetRepository userPasswordResetRepository); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setUserRepository(UserQueryRepository userRepository); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setPasswordResetTokenGenerator(PasswordResetTokenGenerator passwordResetTokenGenerator); static List<String> DEFAULT_ROLES; }### Answer:
@Test public void testHandleUpdateNotificationCommand() { UserId aggregateIdentifier = new UserId(); final Date time = currentTime(); final Identifier identifier = new Identifier(Identifier.Type.IDENTITY_CARD, "110101201101019252"); UserEntry userEntry = new UserEntry(); userEntry.setUsername("buyer1"); userEntry.setPrimaryKey(aggregateIdentifier.toString()); userEntry.setLastName("Buyer One"); userEntry.setFirstName("Mr"); userEntry.setIdentifier(identifier); when(userQueryRepository.findByUsername("buyer1")).thenReturn(userEntry); UpdateNotificationSettingsCommand command = new UpdateNotificationSettingsCommand(aggregateIdentifier, "buyer1", true, false, true, false); fixture.given(new UserCreatedEvent(aggregateIdentifier, "buyer1", "Mr", "Buyer One", identifier, "buyer1@163.com", passwordEncoder.encode("buyer1"), UserCommandHandler.DEFAULT_ROLES, time)) .when(command) .expectEvents( new NotificationSettingsUpdatedEvent( aggregateIdentifier, "buyer1", true, false, true, false)); }