StaticMessageContentBuilder extends AbstractMessageContentBuilder { @Override public Map<String, Object> buildMessageHeaders(final TestContext context) { final Map<String, Object> headers = super.buildMessageHeaders(context); headers.putAll(context.resolveDynamicValuesInMap(message.getHeaders().entrySet() .stream() .filter(entry -> !entry.getKey().equals(MessageHeaders.ID) && !entry.getKey().equals(MessageHeaders.TIMESTAMP)) .collect(HashMap::new, (map, value) -> map.put(value.getKey(), value.getValue()), HashMap::putAll))); return headers; } StaticMessageContentBuilder(final Message message); @Override Object buildMessagePayload(final TestContext context, final String messageType); @Override Map<String, Object> buildMessageHeaders(final TestContext context); @Override List<String> buildMessageHeaderData(final TestContext context); static StaticMessageContentBuilder withMessage(final Message message); Message getMessage();  }
@Test public void testNullValueInHeaders() { messageBuilder = new StaticMessageContentBuilder(new DefaultMessage() .setHeader("foo", "bar") .setHeader("bar", null)); final Map<String, Object> headers = messageBuilder.buildMessageHeaders(context); Assert.assertTrue(headers.containsKey("bar")); Assert.assertNull(headers.get("bar")); Assert.assertTrue(headers.containsKey("foo")); Assert.assertNotNull(headers.get("foo")); Assert.assertEquals(headers.get("foo"), "bar"); }