AuditController { @SuppressWarnings("unchecked") public void addAuditEvent( EntityDelegator e, String auditEventType, String comment, String detail ) { AbstractAuditable entity = this.getAuditable( e ); if ( entity == null ) { AuditController.log.warn( "Couldn't find Auditable represented by " + e ); return; } Class<?> clazz; try { clazz = Class.forName( "ubic.gemma.model.common.auditAndSecurity.eventType." + auditEventType ); } catch ( ClassNotFoundException e1 ) { throw new RuntimeException( "Unknown event type: " + auditEventType ); } AuditEvent auditEvent = auditTrailService .addUpdateEvent( entity, ( Class<? extends AuditEventType> ) clazz, comment, detail ); if ( auditEvent == null ) { AuditController.log.error( "Persisting the audit event failed! On auditable id " + entity.getId() ); } else { AuditController.log.info( "created new event: " + auditEvent ); } }  @SuppressWarnings("unchecked") void addAuditEvent( EntityDelegator e, String auditEventType, String comment, String detail ); Collection<AuditEventValueObject> getEvents( EntityDelegator e );  }
@Test public void testAddUpdateEvent() { ExpressionExperiment e = this.getTestPersistentExpressionExperiment(); EntityDelegator ed = new EntityDelegator( e ); assertEquals( "ubic.gemma.model.expression.experiment.ExpressionExperiment", ed.getClassDelegatingFor() ); auditController.addAuditEvent( ed, "CommentedEvent", "foo", "bar" ); e = expressionExperimentService.load( e.getId() ); assertNotNull( e ); e = expressionExperimentService.thawLite( e ); assertNotNull( e ); AuditTrail auditTrail = e.getAuditTrail(); assertNotNull( auditTrail ); AuditEvent lastEvent = auditTrail.getLast(); assertNotNull( lastEvent ); AuditEventType eventType = lastEvent.getEventType(); assertNotNull( eventType ); assertEquals( CommentedEvent.class, eventType.getClass() ); }