### Question:
GatewayMap extends LinkedHashMap<String, Object> { @Override public Object put(String keyPath, Object value) { String[] properties = keyPath.split("\\."); Map<String, Object> destinationObject = this; if (properties.length > 1) { for (int i = 0; i < (properties.length - 1); i++) { String property = properties[i]; if (property.contains("[")) { destinationObject = getDestinationMap(property, destinationObject, i == properties.length - 1); } else { destinationObject = getPropertyMapFrom(property, destinationObject); } } } else if (keyPath.contains("[")) { destinationObject = getDestinationMap(keyPath, this, true); } if (destinationObject == this) { return super.put(keyPath, value); } else if (value instanceof Map) { destinationObject.clear(); GatewayMap m = new GatewayMap(); m.putAll((Map<? extends String, ? extends Object>) value); destinationObject.put(properties[properties.length - 1], m); return destinationObject; } else { return destinationObject.put(properties[properties.length - 1], value); } } GatewayMap(int initialCapacity, float loadFactor);  GatewayMap(int initialCapacity);  GatewayMap();  GatewayMap(Map<String, Object> map);  GatewayMap(String jsonMapString);  GatewayMap(String keyPath, Object value); @Override Object put(String keyPath, Object value); GatewayMap set(String keyPath, Object value); @Override Object get(Object keyPath); @Override boolean containsKey(Object keyPath); @Override Object remove(Object keyPath); static Map<String, Object> normalize(Map<String, Object> m);  }### Answer:
@Test public void cannotOverrideNestedMap() { GatewayMap map = new GatewayMap(); map.put("a", 1); try { map.put("a.b", 2); fail("IllegalArgumentException not raised"); } catch (IllegalArgumentException e) { } catch (Exception e) { fail("Exception " + e + " thrown"); } }