CorrelationContext { void deserialize(String value) { if (StringUtil.isEmpty(value)) { return; } for (String perData : value.split(",")) { if (data.size() >= Config.Correlation.ELEMENT_MAX_NUMBER) { break; } final String[] parts = perData.split(":"); if (parts.length != 2) { continue; } data.put(Base64.decode2UTFString(parts[0]), Base64.decode2UTFString(parts[1])); } } 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 testDeserialize() { CorrelationContext context = new CorrelationContext(); context.deserialize("dGVzdDE=:dDE=,dGVzdDI=:dDI="); Assert.assertEquals("t1", context.get("test1").get()); Assert.assertEquals("t2", context.get("test2").get()); context = new CorrelationContext(); context.deserialize("dGVzdDE=:"); Assert.assertFalse(context.get("test1").isPresent()); context = new CorrelationContext(); context.deserialize(""); Assert.assertNull(context.get("test1").orElse(null)); context.deserialize(null); Assert.assertNull(context.get("test1").orElse(null)); }