@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());
}