### Question:
ContextTransformer implements Transformer { @Override public Object transform(Object o) { return transform(key, o); } ContextTransformer(String key); String getKey(); @Override Object transform(Object o); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void testTransformSimple() { Map<String, Object> context = new HashMap<>(); context.put("key", "value"); context.put("key1", "value1"); context.put("key2", "value2"); ContextTransformer transformer = new ContextTransformer("key"); Assert.assertEquals("value", transformer.transform(context)); }
@Test public void testTransformTree() { Map<String, Object> serviceSite = new HashMap<>(); serviceSite.put("property", "service-site-property"); Map<String, Object> configurations = new HashMap<>(); configurations.put("service-site", serviceSite); configurations.put("property", "configuration-property"); Map<String, Object> context = new HashMap<>(); context.put("configurations", configurations); context.put("property", "context-property"); ContextTransformer transformer; transformer = new ContextTransformer("configurations/service-site/property"); Assert.assertEquals("service-site-property", transformer.transform(context)); transformer = new ContextTransformer("/configurations/service-site/property"); Assert.assertEquals("service-site-property", transformer.transform(context)); transformer = new ContextTransformer("/configurations/service-site"); Assert.assertEquals(serviceSite, transformer.transform(context)); }