TypedProperties { @SuppressWarnings("unchecked") public final <T> T getValue(final E key) { return (T) cache.get(key).getValue(); } protected  TypedProperties(final Class<E> keyClass, final Properties props); @SuppressWarnings("unchecked") final T getValue(final E key);  }
@Test public void assertGetValue() { Properties props = new Properties(); props.setProperty(TestTypedPropertyKey.BOOLEAN_VALUE.getKey(), Boolean.TRUE.toString()); props.setProperty(TestTypedPropertyKey.BOOLEAN_OBJECT_VALUE.getKey(), Boolean.TRUE.toString()); props.setProperty(TestTypedPropertyKey.INT_VALUE.getKey(), "100"); props.setProperty(TestTypedPropertyKey.INT_OBJECT_VALUE.getKey(), "100"); props.setProperty(TestTypedPropertyKey.LONG_VALUE.getKey(), "10000"); props.setProperty(TestTypedPropertyKey.LONG_OBJECT_VALUE.getKey(), "10000"); props.setProperty(TestTypedPropertyKey.STRING_VALUE.getKey(), "new_value"); TestTypedProperties actual = new TestTypedProperties(props); assertTrue(actual.getValue(TestTypedPropertyKey.BOOLEAN_VALUE)); assertTrue(actual.getValue(TestTypedPropertyKey.BOOLEAN_OBJECT_VALUE)); assertThat(actual.getValue(TestTypedPropertyKey.INT_VALUE), is(100)); assertThat(actual.getValue(TestTypedPropertyKey.INT_OBJECT_VALUE), is(100)); assertThat(actual.getValue(TestTypedPropertyKey.LONG_VALUE), is(10000L)); assertThat(actual.getValue(TestTypedPropertyKey.LONG_OBJECT_VALUE), is(10000L)); assertThat(actual.getValue(TestTypedPropertyKey.STRING_VALUE), is("new_value")); }
@Test public void assertGetDefaultValue() { TestTypedProperties actual = new TestTypedProperties(new Properties()); assertFalse(actual.getValue(TestTypedPropertyKey.BOOLEAN_VALUE)); assertFalse(actual.getValue(TestTypedPropertyKey.BOOLEAN_OBJECT_VALUE)); assertThat(actual.getValue(TestTypedPropertyKey.INT_VALUE), is(10)); assertThat(actual.getValue(TestTypedPropertyKey.INT_OBJECT_VALUE), is(10)); assertThat(actual.getValue(TestTypedPropertyKey.LONG_VALUE), is(1000L)); assertThat(actual.getValue(TestTypedPropertyKey.LONG_OBJECT_VALUE), is(1000L)); assertThat(actual.getValue(TestTypedPropertyKey.STRING_VALUE), is("value")); }