### Question:
EventService implements DisposableBean { public void publish(final Event event) { if (event == null) { return; } try { event.validate(); final boolean queued = eventQueue.offer(event); if (!queued) { LOGGER.error("Unable to queue event because queue is full"); } } catch (IllegalStateException e) { LOGGER.error("Invalid event due to: " + e.getMessage(), e); } } @Autowired  EventService(final List<EventHookProvider> eventHookProviders); @PostConstruct void postConstruct(); @Override void destroy(); void publish(final Event event);  }### Answer:
@Test public void testPublishConsume() throws InterruptedException { final Bucket bucket = new Bucket(); bucket.setIdentifier(UUID.randomUUID().toString()); final Event bucketCreatedEvent = EventFactory.bucketCreated(bucket); eventService.publish(bucketCreatedEvent); final Event bucketDeletedEvent = EventFactory.bucketDeleted(bucket); eventService.publish(bucketDeletedEvent); Thread.sleep(1000); final List<Event> events = eventHook.getEvents(); Assert.assertEquals(2, events.size()); final Event firstEvent = events.get(0); Assert.assertEquals(bucketCreatedEvent.getEventType(), firstEvent.getEventType()); final Event secondEvent = events.get(1); Assert.assertEquals(bucketDeletedEvent.getEventType(), secondEvent.getEventType()); }