AuditSupport implements Serializable { public void fireAudit(String serviceName, List<GenericAuditEntity> auditEntities) { if (null != serviceName && null != auditEntities && 0 != auditEntities.size()) { fireAudit(new AuditEvent(this.source, serviceName, auditEntities)); } } AuditSupport(Object sourceBean); void addAuditListener(AuditListener listener); void addAuditListener(String propertyName, AuditListener listener); void removeAuditListener(AuditListener listener); void removeAuditListener(String propertyName, AuditListener listener); void fireAudit(String serviceName, List<GenericAuditEntity> auditEntities); void fireAudit(AuditEvent event); AuditListener[] getAuditListeners(); AuditListener[] getAuditListeners(String propertyName); boolean hasListeners(String propertyName);  }
@Test public void testFireAudit() throws Exception { AuditSupport auditSupport = new AuditSupport(this); Field mapField = AuditSupport.class.getDeclaredField("map"); mapField.setAccessible(true); AuditListenerMap map = (AuditListenerMap)mapField.get(auditSupport); AuditListener auditListener1 = new AuditListenerTestHelper(); AuditListener auditListener2 = new AuditListenerTestHelper(); AuditListener[] listeners = {auditListener1, auditListener2}; map.set("testServiceName", listeners); map.set(null, listeners); List<GenericAuditEntity> auditEntities = new ArrayList<>(); GenericAuditEntity genericAuditEntity = new GenericAuditEntity(); auditEntities.add(genericAuditEntity); auditSupport.fireAudit("testServiceName", auditEntities); }