CorrelationContext { String serialize() { if (data.isEmpty()) { return ""; } return data.entrySet().stream() .map(entry -> Base64.encode(entry.getKey()) + ":" + Base64.encode(entry.getValue())) .collect(Collectors.joining(",")); } CorrelationContext(); Optional<String> put(String key, String value); Optional<String> get(String key); CorrelationContext clone(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testSerialize() { CorrelationContext context = new CorrelationContext(); context.put("test1", "t1"); context.put("test2", "t2"); Assert.assertEquals("dGVzdDE=:dDE=,dGVzdDI=:dDI=", context.serialize()); context = new CorrelationContext(); context.put("test1", null); Assert.assertEquals("", context.serialize()); context = new CorrelationContext(); Assert.assertEquals("", context.serialize()); }