### Question:
ParameterHelper implements JournalConstants { public static boolean getOptionalBooleanParameter(Map<String, String> parameters, String parameterName, boolean defaultValue) throws JournalException { validateParameters(parameters); validateParameterName(parameterName); String string = parameters.get(parameterName); if (string == null) { return defaultValue; } else if (string.equals(VALUE_FALSE)) { return false; } else if (string.equals(VALUE_TRUE)) { return true; } else { throw new JournalException("'" + parameterName + "' parameter must be '" + VALUE_FALSE + "'(default) or '" + VALUE_TRUE + "'"); } } private  ParameterHelper(); static String getOptionalStringParameter(Map<String, String> parameters,
                                                    String parameterName,
                                                    String defaultValue); static boolean getOptionalBooleanParameter(Map<String, String> parameters,
                                                      String parameterName,
                                                      boolean defaultValue); static File parseParametersForWritableDirectory(Map<String, String> parameters,
                                                           String parameterName); static String parseParametersForFilenamePrefix(Map<String, String> parameters); static long parseParametersForSizeLimit(Map<String, String> parameters); static long parseParametersForAgeLimit(Map<String, String> parameters);  }### Answer:
@Test public void testGetOptionalBooleanParameter_NullParameters() throws JournalException { try { ParameterHelper.getOptionalBooleanParameter(null, PARAMETER_NAME, false); fail("Expected a NullPointerException"); } catch (NullPointerException e) { } }
@Test public void testGetOptionalBooleanParameter_NullParameterName() throws JournalException { try { ParameterHelper .getOptionalBooleanParameter(parameters, null, false); fail("Expected a NullPointerException"); } catch (NullPointerException e) { } }
@Test public void testGetOptionalBooleanParameter_ValueTrue() throws JournalException { parameters.put(PARAMETER_NAME, VALUE_TRUE); boolean result = ParameterHelper.getOptionalBooleanParameter(parameters, PARAMETER_NAME, false); assertEquals(true, result); }
@Test public void testGetOptionalBooleanParameter_ValueFalse() throws JournalException { parameters.put(PARAMETER_NAME, VALUE_FALSE); boolean result = ParameterHelper.getOptionalBooleanParameter(parameters, PARAMETER_NAME, true); assertEquals(false, result); }
@Test public void testGetOptionalBooleanParameter_NoValue() throws JournalException { boolean result1 = ParameterHelper.getOptionalBooleanParameter(parameters, PARAMETER_NAME, true); assertEquals(true, result1); boolean result2 = ParameterHelper.getOptionalBooleanParameter(parameters, PARAMETER_NAME, false); assertEquals(false, result2); }
@Test public void testGetOptionalBooleanParameter_InvalidValue() { parameters.put(PARAMETER_NAME, "BOGUS"); try { ParameterHelper.getOptionalBooleanParameter(parameters, PARAMETER_NAME, false); fail("Expected a JournalException"); } catch (JournalException e) { } }