### Question:
DefaultCorrelationPostProcessor implements CorrelationPostProcessor { @Override public Message postProcessMessage(final Message message) { MessageProperties messageProperties = message.getMessageProperties(); String correlationId = messageProperties.getCorrelationId(); if (correlationId == null) { correlationId = (tracer!=null && tracer.currentSpan()!=null)? tracer.currentSpan().context().traceIdString():UUID.randomUUID().toString(); messageProperties.setCorrelationId(correlationId); } messageProperties.getHeaders().put("correlation-id", correlationId); return message; } @Autowired(required = false)  DefaultCorrelationPostProcessor(Tracer tracer); @Override Message postProcessMessage(final Message message);  }### Answer:
@Test public void addNewCorrelationIdToHeaderIfMissingTest() { correlationPostProcessor.postProcessMessage(message); assertNotNull(message.getMessageProperties().getHeaders().get("correlation-id")); }
@Test public void addNewCorrelationIdFromTracerToHeaderIfMissingTest() { correlationPostProcessor.postProcessMessage(message); assertNotNull(message.getMessageProperties().getHeaders().get("correlation-id")); assertThat(message.getMessageProperties().getHeaders().get("correlation-id"), equalTo(tracer.currentSpan().context().traceIdString())); }
@Test public void addExistingCorrelationIdToHeaderIfPresentTest() { message.getMessageProperties().setCorrelationId("ExistingCorrelationId"); correlationPostProcessor.postProcessMessage(message); assertNotNull(message.getMessageProperties().getHeaders().get("correlation-id")); assertThat(message.getMessageProperties().getHeaders().get("correlation-id"), is(equalTo("ExistingCorrelationId"))); }