### Question:
TypedSettings { public String getString(String key, String defaultValue) { Object value = map.get(key); if (value == null) { return defaultValue; } else if (value instanceof String) { return (String) value; } else { throw new ClassCastException(errorMessage(key, value, "String")); } } TypedSettings(Map<String, Object> map); String getString(String key, String defaultValue); boolean getBoolean(String key, boolean defaultValue); int getInt(String key, int defaultValue); long getLong(String key, int defaultValue); double getDouble(String key, double defaultValue); float getFloat(String key, float defaultValue); Object getObject(String key, Object defaultValue); static final String DRY_RUN_SETTING_NAME; static final String TASK_CONTEXT_SETTING_NAME; }### Answer:
@Test public void testString() throws Exception { String key = "myKey"; assertEquals("true", settings.getString(key, "true")); assertEquals("blue", settings.getString(key, "blue")); map.put(key, "red"); assertEquals("red", settings.getString(key, "blue")); map.put(key, new Object()); try { settings.getString(key, "foo"); fail(); } catch (ClassCastException e) { ; } }