DomaEventEntityListener extends NullEntityListener<T> implements
		ApplicationEventPublisherAware { @Override public void preDelete(T t, PreDeleteContext<T> context) { this.eventPublisher.publishEvent(new PreDeleteEvent<>(t, context)); }  @Override void preInsert(T t, PreInsertContext<T> context); @Override void preUpdate(T t, PreUpdateContext<T> context); @Override void preDelete(T t, PreDeleteContext<T> context); @Override void postInsert(T t, PostInsertContext<T> context); @Override void postUpdate(T t, PostUpdateContext<T> context); @Override void postDelete(T t, PostDeleteContext<T> context); @Override void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher);  }
@Test public void handlePreDelete() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); context.register(PreDeleteHandler.class); context.refresh(); DomaEventEntityListener<Entity> entityListener = context .getBean(DomaEventEntityListener.class); PreDeleteContext ctx = mock(PreDeleteContext.class); Entity entity = new Entity(); entityListener.preDelete(entity, ctx); PreDeleteHandler handler = context.getBean(PreDeleteHandler.class); assertThat(handler.entity).isSameAs(entity); }
@Test public void handlePreDeleteWithContext() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); context.register(PreDeleteHandlerWithContext.class); context.refresh(); DomaEventEntityListener<Entity> entityListener = context .getBean(DomaEventEntityListener.class); PreDeleteContext ctx = mock(PreDeleteContext.class); Entity entity = new Entity(); entityListener.preDelete(entity, ctx); PreDeleteHandlerWithContext handler = context .getBean(PreDeleteHandlerWithContext.class); assertThat(handler.entity).isSameAs(entity); assertThat(handler.ctx).isSameAs(ctx); }