Context { public Context createChild(String name) { Preconditions.checkArgument(name.indexOf('/') == -1, "name must not contain a slash"); Preconditions.checkArgument(!children.containsKey(name), "child with name '%s' already exists", name); Preconditions.checkArgument(!values.containsKey(name), "name identifies a key-value pair", "createChild operation not allowed"); Context child = new Context(); children.put(name, child); return child; }  Set<String> getKeys(); String get(String key); void put(String key, String value); Map<String, Context> getChildren(); Context getChild(String name); Context createChild(String name); void remove(String nameOrKey); void setId(String id); String getId(); @Override String toString();  }
@Test(expected = IllegalArgumentException.class) public void testCreatingNewChildWithSlashInName_shouldThrowIllegalArgumentException() throws Exception { context.createChild("with/slash"); }
@Test(expected = IllegalArgumentException.class) public void testCreateChildWithExistingNamedChild_shouldThrowIllegalArgumentException() throws Exception { context.createChild("a"); context.createChild("a"); }