### Question:
MoveTransformationRule implements SchemaTransformationRule { @Override public Map<String, Object> transform(Map<String, Object> event) { Map<String, Object> objectToMove = (Map<String, Object>) ((HashMap<String, Object>) getItem(event, oldKey)).clone(); Map<String, Object> resultEvent = addItem(event, newKey, objectToMove); resultEvent = deleteItem(resultEvent, oldKey); return resultEvent; } MoveTransformationRule(List<String> oldKey, List<String> newKey); @Override Map<String, Object> transform(Map<String, Object> event);  }### Answer:
@Test public void transform() { Map<String, Object> child = new HashMap<>(); child.put("key", new HashMap<>()); Map<String, Object> event = new HashMap<>(); event.put("old_parent", child); event.put("new_parent", new HashMap<>()); List<String> oldKey = new ArrayList<>(); oldKey.add("old_parent"); oldKey.add("key"); List<String> newKey = new ArrayList<>(); newKey.add("new_parent"); MoveTransformationRule moveRule = new MoveTransformationRule(oldKey, newKey); Map<String, Object> result = moveRule.transform(event); assertEquals(2, result.keySet().size()); assertEquals(0, ((Map<String, Object>) result.get("old_parent")).keySet().size()); assertEquals(1, ((Map<String, Object>) result.get("new_parent")).keySet().size()); }
@Test public void transFormTopLevelProperty() { Map<String, Object> event = new HashMap<>(); event.put("new_parent", new HashMap<>()); event.put("toMove", "x"); MoveTransformationRule moveRule = new MoveTransformationRule(Arrays.asList("toMove"), Arrays.asList("new_parent")); Map<String, Object> result = moveRule.transform(event); assertEquals(1, result.keySet().size()); assertEquals(1, ((Map<String, Object>) result.get("new_parent")).keySet().size()); }
@Test public void transToTopLevelProperty() { Map<String, Object> child = new HashMap<>(); child.put("child", "value"); Map<String, Object> parent = new HashMap<>(); parent.put("parent", child); MoveTransformationRule moveRule = new MoveTransformationRule(Arrays.asList("parent", "child"), Arrays.asList("")); Map<String, Object> result = moveRule.transform(parent); assertEquals(2, result.keySet().size()); assertEquals(0, ((Map<String, Object>) result.get("parent")).keySet().size()); assertEquals("value", result.get("child")); }