### Question:
TraceeTopicPublisher implements TopicPublisher { @Override public void publish(Message message) throws JMSException { messageProducer.writeTraceeContextToMessage(message); delegate.publish(message); } TraceeTopicPublisher(TraceeMessageProducer messageProducer, TopicPublisher delegate); @Override Topic getTopic(); @Override void publish(Message message); @Override void publish(Message message, int deliveryMode, int priority, long timeToLive); @Override void publish(Topic topic, Message message); @Override void publish(Topic topic, Message message, int deliveryMode, int priority, long timeToLive); @Override void send(Message message); @Override void send(Message message, int deliveryMode, int priority, long timeToLive); @Override void send(Destination destination, Message message); @Override void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive); @Override void setDisableMessageID(boolean value); @Override boolean getDisableMessageID(); @Override void setDisableMessageTimestamp(boolean value); @Override boolean getDisableMessageTimestamp(); @Override void setDeliveryMode(int deliveryMode); @Override int getDeliveryMode(); @Override void setPriority(int defaultPriority); @Override int getPriority(); @Override void setTimeToLive(long timeToLive); @Override long getTimeToLive(); @Override Destination getDestination(); @Override void close();  }### Answer:
@Test public void publishMessageShouldAddContextAndDelegate() throws Exception { unit.publish(message); verify(message).setStringProperty(eq(TraceeConstants.TPIC_HEADER), anyString()); verify(topicPublisher).publish(message); }
@Test public void publishMessageWithTopicShouldAddContextAndDelegate() throws Exception { final Topic topic = mock(Topic.class); unit.publish(topic, message); verify(message).setStringProperty(eq(TraceeConstants.TPIC_HEADER), anyString()); verify(topicPublisher).publish(topic, message); }
@Test public void publishMessageWithDeliveryModeAndPriorityAndTTLShouldAddContextAndDelegate() throws Exception { unit.publish(message, DeliveryMode.PERSISTENT, 5, 100); verify(message).setStringProperty(eq(TraceeConstants.TPIC_HEADER), anyString()); verify(topicPublisher).publish(message, DeliveryMode.PERSISTENT, 5, 100); }
@Test public void publishMessageWithTopicAndDeliveryModeAndPriorityAndTTLShouldAddContextAndDelegate() throws Exception { final Topic topic = mock(Topic.class); unit.publish(topic, message, DeliveryMode.PERSISTENT, 5, 100); verify(message).setStringProperty(eq(TraceeConstants.TPIC_HEADER), anyString()); verify(topicPublisher).publish(topic, message, DeliveryMode.PERSISTENT, 5, 100); }