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