AuthenticationFailedEventListener extends SecurityEventListener { @Override public void audit(SecurityEvent event) { AuthenticationFailedEvent authenticationFailedEvent = (AuthenticationFailedEvent) event; Map<PredicateKey, String> predicateMap = auditService .createPredicateMap(); predicateMap.put(SecurityPredicateKey.IP_ADDRESS, event.getIpAddress()); try { auditService.audit("AuthenticationFailedEventListener", authenticationFailedEvent.getIpAddress(), SecurityAuditVerb.FAILED_ATTEMPTS_TO_LOGIN_AS, authenticationFailedEvent.getUserName(), predicateMap); } catch (AuditException e) { logger.error(e.getMessage(), e); } } AuthenticationFailedEventListener(EventService eventService,
			AuditService auditService); @Override boolean canHandle(Object event); @Override void handle(Object event); @Override void audit(SecurityEvent event);  }
@Test public void testAudit() throws AuditException { @SuppressWarnings("unchecked") Map<PredicateKey, String> predicateMap=(Map<PredicateKey, String>)mock(Map.class); doReturn(predicateMap).when(auditService).createPredicateMap(); SecurityEvent event=new AuthenticationFailedEvent(IP_ADDRESS, USER_NAME); listener.audit(event); verify(auditService).audit("AuthenticationFailedEventListener", IP_ADDRESS, SecurityAuditVerb.FAILED_ATTEMPTS_TO_LOGIN_AS, USER_NAME, predicateMap); }