### Question:
CommonsConfigurationSource implements ConfigurationSource { @Override @SuppressWarnings("unchecked") public <T> T getProperty(String key, T defaultValue) { T result; if (containsKey(key)) { if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } } else { result = defaultValue; } return result; }  @Override @SuppressWarnings("unchecked") T getProperty(String key, T defaultValue); @Override @SuppressWarnings("unchecked") T getProperty(String key); @Override @SuppressWarnings("unchecked") T getProperty(String key, Class<T> valueClass); @Override List<String> getKeys(); @Override boolean containsKey(String key); @Override boolean isEmpty();  }### Answer:
@Test void testDefaultValue() { this.configuration.setProperty("string", "value"); assertEquals("default", this.source.getProperty("unknown", "default")); assertEquals("value", this.source.getProperty("string", "default")); assertEquals(null, this.source.getProperty("unknown", (String) null)); }
@Test void testStringProperty() { this.configuration.setProperty("string", "value"); assertEquals("value", this.source.getProperty("string")); assertEquals("value", this.source.getProperty("string", String.class)); assertNull(this.source.getProperty("unknown")); assertNull(this.source.getProperty("unknown", String.class)); }
@Test void testStringPropertyWhenConversionError() { this.configuration.setProperty("string", "value"); Exception exception = assertThrows(ConversionException.class, () -> this.source.getProperty("string", Boolean.class)); assertEquals("Key [string] is not compatible with type [java.lang.Boolean]", exception.getMessage()); }
@Test void testBooleanPropertyWhenConversionError() { this.configuration.setProperty("property", ""); Exception exception = assertThrows(ConversionException.class, () -> this.source.getProperty("property", Color.class)); assertEquals("Key [property] is not compatible with type [java.awt.Color]", exception.getMessage()); }
@Test void testBooleanProperty() { this.configuration.setProperty("boolean", true); assertEquals(true, this.source.getProperty("boolean")); assertEquals(true, this.source.getProperty("boolean", Boolean.class)); assertEquals(true, this.source.getProperty("unknown", true)); assertEquals(false, this.source.getProperty("unknown", false)); }
@Test void testUnknownBooleanProperty() { assertNull(this.source.getProperty("unknown", Boolean.class)); }
@Test void testListPropertyWhenArrayList() { this.configuration.setProperty("list", "value"); List<String> expected = Arrays.asList("value"); assertEquals(expected, this.source.getProperty("list", Arrays.asList("default"))); }