### Question:
JsonObjectImpl extends AbstractMap<String, JsonValue> implements JsonObject, Serializable { @Override public boolean getBoolean(final String name) { final JsonValue obj = valueOrExcpetion(name, JsonValue.class); if (JsonValue.TRUE == obj) { return true; } if (JsonValue.FALSE == obj) { return false; } throw new ClassCastException("Wrong value for a boolean: " + obj); } JsonObjectImpl(final Map<String, JsonValue> backingMap, final BufferStrategy.BufferProvider<char[]> provider); @Override JsonArray getJsonArray(final String name); @Override JsonObject getJsonObject(final String name); @Override JsonNumber getJsonNumber(final String name); @Override JsonString getJsonString(final String name); @Override String getString(final String name); @Override String getString(final String name, final String defaultValue); @Override int getInt(final String name); @Override int getInt(final String name, final int defaultValue); @Override boolean getBoolean(final String name); @Override boolean getBoolean(final String name, final boolean defaultValue); @Override boolean isNull(final String name); @Override ValueType getValueType(); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override Set<java.util.Map.Entry<String, JsonValue>> entrySet(); @Override void clear(); @Override JsonValue remove(final Object key);  }### Answer:
@Test public void boolErrors() { { final JsonObject val = Json.createObjectBuilder().add("a", true).build(); assertTrue(val.getBoolean("a")); } { final JsonObject val = Json.createObjectBuilder().add("a", "wrong").build(); try { val.getBoolean("a"); fail(); } catch (final ClassCastException cce) { } } }
@Test(expected = NullPointerException.class) public void testGetBooleanMissingKeyShouldThrowNullPointerException() { getObject().getBoolean("missing"); }
@Test public void testGetBooleanWithDefaultMissingKeyShouldReturnDefault() { assertTrue(getObject().getBoolean("missing", true)); }