### Question:
HermesAbstractApiListener extends HttpRequestAdaptor { public Boolean getOptionalBooleanFromInput(Map<String, Object> inputDict, String key, boolean defaultValue, Map<String, Object> error) { Boolean value = null; try { value = (Boolean) inputDict.get(key); if (value == null) { value = defaultValue; } } catch (Exception e) { String errorMessage = "Error parsing parameter: " + key; logError(errorMessage, e); fillError(error, ErrorCode.ERROR_PARSING_REQUEST, errorMessage); } return value; } HermesAbstractApiListener(); void fillError(Map<String, Object> error, int code, String message); Map<String, Object> createError(int code, String message); Map<String, Object> createActionResult(String id, boolean success); String processRequest(HttpServletRequest request, HttpServletResponse response); String getStringFromInput(Map<String, Object> inputDict, String key, Map<String, Object> error); Long getLongFromInput(Map<String, Object> inputDict, String key, Map<String, Object> error); String getOptionalStringFromInput(Map<String, Object> inputDict, String key, String defaultValue, Map<String, Object> error); Long getOptionalLongFromInput(Map<String, Object> inputDict, String key, long defaultValue, Map<String, Object> error); Boolean getOptionalBooleanFromInput(Map<String, Object> inputDict, String key, boolean defaultValue, Map<String, Object> error);  }### Answer:
@Test public void testGetOptionalBooleanFromInput() { Map<String, Object> input = new HashMap<String, Object>(); input.put("key1", new Boolean(false)); input.put("key2", "string"); Map<String, Object> error = new HashMap<String, Object>(); boolean defaultValue = true; Assert.assertEquals(new Boolean(false), listener.getOptionalBooleanFromInput(input, "key1", defaultValue, error)); Assert.assertEquals(0, error.size()); Assert.assertEquals(null, listener.getOptionalBooleanFromInput(input, "key2", defaultValue, error)); Assert.assertEquals(2, error.size()); error.clear(); Assert.assertEquals(new Boolean(defaultValue), listener.getOptionalBooleanFromInput(input, "key3", defaultValue, error)); Assert.assertEquals(0, error.size()); }