### Question:
SubConfiguration implements Configuration { public boolean getBoolean(String propertyName){ return cfg.getBoolean(prefix + propertyName); } SubConfiguration();  SubConfiguration(Configuration cfg, String prefix); void setConfiguration(Configuration newCfg); void setPrefix(String newPrefix); String get(String propertyName); String[] getAll(String propertyName); int[] getInts(String propertyName); long[] getLongs(String propertyName); double[] getDoubles(String propertyName); boolean[] getBooleans(String propertyName); String get(String propertyName, String defaultValue); boolean getBoolean(String propertyName); boolean getBoolean(String propertyName, boolean defaultValue); double getDouble(String propertyName); double getDouble(String propertyName, double defaultValue); long getLong(String propertyName); long getLong(String propertyName, long defaultValue); int getInt(String propertyName); int getInt(String propertyName, int defaultValue); void put(String name, Object value); Object getObject(String propertyName); @Override Set<String> keySet();  }### Answer:
@Test public void testGetBoolean() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); boolean result = subConfiguration.getBoolean("testSubConfigurationPropertyName"); assertFalse(result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetBoolean1() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); boolean result = subConfiguration.getBoolean("testSubConfigurationPropertyName", false); assertFalse(result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetBoolean2() throws Throwable { Configuration cfg = new SimpleConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); boolean result = subConfiguration.getBoolean("testSubConfigurationPropertyName", true); assertTrue(result, "result"); assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); }
@Test public void testGetBooleanThrowsNullPointerException() throws Throwable { Configuration cfg = new SubConfiguration(new SubConfiguration(), "testSubConfigurationPrefix"); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix1"); try { subConfiguration.getBoolean("testSubConfigurationPropertyName"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.getBoolean(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertSame(cfg, subConfiguration.cfg, "subConfiguration.cfg"); } }
@Test public void testGetBooleanThrowsNullPointerException1() throws Throwable { SubConfiguration subConfiguration = new SubConfiguration(); try { subConfiguration.getBoolean("testSubConfigurationPropertyName", true); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.getBoolean(String, boolean)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(subConfiguration.cfg, "subConfiguration.cfg"); } }