LoginSuccessEventListener extends EventListener { @Override public void handle(Object event) { AuthenticationSuccessEvent loginSuccessEvent = (AuthenticationSuccessEvent) event; Object name = loginSuccessEvent.getAuthentication().getPrincipal(); if (name != null) { Users user = (Users) name; user.setFailedLoginAttemptsToZero(); usersRepository.updateUser(user); } } LoginSuccessEventListener(EventService eventService,
			UsersRepository usersRepository); @Override boolean canHandle(Object event); @Override void handle(Object event);  }
@Test public void testHandle() { AuthenticationSuccessEvent loginSuccessEvent=mock(AuthenticationSuccessEvent.class); Authentication authentication=mock(Authentication.class); Users user=mock(Users.class); when(loginSuccessEvent.getAuthentication()).thenReturn(authentication); when(authentication.getPrincipal()).thenReturn(user); loginSuccessEventListener.handle(loginSuccessEvent); verify(user).setFailedLoginAttemptsToZero(); verify(usersRepository).updateUser(user); }