AuditSupport implements Serializable { public void addAuditListener(AuditListener listener) { if (listener == null) return; if (listener instanceof AuditListenerProxy) { AuditListenerProxy proxy = (AuditListenerProxy) listener; addAuditListener(proxy.getPropertyName(), proxy.getListener()); } else { this.map.add(null, listener); } } 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 addAuditLFieldListenerNull() throws Exception { AuditSupport auditSupport = new AuditSupport(this); Field mapField = AuditSupport.class.getDeclaredField("map"); mapField.setAccessible(true); AuditListenerMap map = (AuditListenerMap)mapField.get(auditSupport); AuditListener auditListener = null; auditSupport.addAuditListener(auditListener); Assert.assertTrue(map.getEntries() == Collections.<Map.Entry<String, AuditListener[]>>emptySet()); }
@Test public void addAuditProxyNullListener() throws Exception { AuditSupport auditSupport = new AuditSupport(this); Field mapField = AuditSupport.class.getDeclaredField("map"); mapField.setAccessible(true); AuditListenerMap map = (AuditListenerMap)mapField.get(auditSupport); AuditListener auditListener = new AuditListenerProxy("test", null); auditSupport.addAuditListener(auditListener); Assert.assertNull(map.get("test")); }
@Test public void addAuditProxyHBase() throws Exception { AuditSupport auditSupport = new AuditSupport(this); Field mapField = AuditSupport.class.getDeclaredField("map"); mapField.setAccessible(true); AuditListenerMap map = (AuditListenerMap)mapField.get(auditSupport); AuditListener auditListener = new AuditListenerTestHelper(); auditSupport.addAuditListener(auditListener); Assert.assertNull(map.get("test")); }