### Question:
ApiNeutralSchemaValidator extends NeutralSchemaValidator { protected Object getValue(String path, Map<String, Object> data) { Object retValue = null; Map<?, ?> values = new HashMap<String, Object>(data); String[] keys = path.split("\\."); for (String key : keys) { Object value = values.get(key); if (Map.class.isInstance(value)) { values = (Map<?, ?>) value; retValue = value; } else { retValue = value; break; } } return retValue; }  @Override boolean validateNaturalKeys(final Entity entity, boolean overWrite);  }### Answer:
@Test public void testGetValueOneLevel() { Map<String, Object> data = new HashMap<String, Object>(); data.put("key1", "value1"); data.put("key2", "value2"); data.put("key3", "value3"); assertEquals("Should match", "value1", apiNeutralSchemaValidator.getValue("key1", data)); assertEquals("Should match", "value2", apiNeutralSchemaValidator.getValue("key2", data)); assertEquals("Should match", "value3", apiNeutralSchemaValidator.getValue("key3", data)); assertEquals("Should match", null, apiNeutralSchemaValidator.getValue("key4", data)); }
@Test public void testGetValueMultiLevel() { Map<String, Object> inner2 = new HashMap<String, Object>(); inner2.put("key7", "value7"); inner2.put("key8", "value8"); Map<String, Object> inner1 = new HashMap<String, Object>(); inner1.put("key4", "value4"); inner1.put("key5", "value5"); inner1.put("key6", inner2); Map<String, Object> data = new HashMap<String, Object>(); data.put("key1", "value1"); data.put("key2", "value2"); data.put("key3", inner1); assertEquals("Should match", "value1", apiNeutralSchemaValidator.getValue("key1", data)); assertEquals("Should match", "value2", apiNeutralSchemaValidator.getValue("key2", data)); assertEquals("Should match", inner1, apiNeutralSchemaValidator.getValue("key3", data)); assertEquals("Should match", "value4", apiNeutralSchemaValidator.getValue("key3.key4", data)); assertEquals("Should match", "value5", apiNeutralSchemaValidator.getValue("key3.key5", data)); assertEquals("Should match", inner2, apiNeutralSchemaValidator.getValue("key3.key6", data)); assertEquals("Should match", "value7", apiNeutralSchemaValidator.getValue("key3.key6.key7", data)); assertEquals("Should match", "value8", apiNeutralSchemaValidator.getValue("key3.key6.key8", data)); }