@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); }
@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 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 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); }
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); }
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);  }