JsonBackedValueObject { public final <T> T getProperty(final String name, final Class<T> clazz) { return getProperty(json, name, clazz); }  final T getProperty(final String name, final Class<T> clazz); final T getProperty(final String name, final Class<T> clazz, final T defaultValue);  }
@Test public void testBooleanDefaultForMissingValue() { final JsonBackedValueObject json = new JsonBackedValueObject() { }; assertNull(json.getProperty("foo", Boolean.class)); assertTrue(json.getProperty("foo", Boolean.class, true)); }
@Test public void testBooleanDefaultForNullValue() { final JsonBackedValueObject json = new JsonBackedValueObject() { }; json.json.put("foo", (Boolean) null); assertNull(json.getProperty("foo", Boolean.class)); assertTrue(json.getProperty("foo", Boolean.class, true)); }
@Test public void testBooleanDefaultForWrongType() { final JsonBackedValueObject json = new JsonBackedValueObject() { }; json.json.put("foo", "bar"); assertNull(json.getProperty("foo", Boolean.class)); assertTrue(json.getProperty("foo", Boolean.class, true)); }