ArchiveController extends AbstractCommandController { protected Map getCustomDepositFormElementsAsMap(HttpServletRequest request) { if (Boolean.parseBoolean(request.getParameter("customDepositForm_customFormPopulated")) == false) { return null; } Enumeration parameterNames = request.getParameterNames(); if (parameterNames == null) return null; Map customDepositFormElements = new HashMap(); while (parameterNames.hasMoreElements()) { String parameterName = (String)parameterNames.nextElement(); if (parameterName.startsWith("customDepositForm_")) { String[] values = request.getParameterValues(parameterName); if (values == null || values.length <=0) continue; customDepositFormElements.put(parameterName, values[0]); } } return customDepositFormElements; } ArchiveController(); void setTargetInstanceManager(TargetInstanceManager targetInstanceManager); void setArchiveAdapter(ArchiveAdapter archiveAdapter); void setTargetManager(TargetManager targetManager); void setHeritrixVersion(String heritrixVersion); void setWebCuratorUrl(String webCuratorUrl); void setSipBuilder(SipBuilder sipBuilder);  }
@Test public final void testGetCustomDepositFormElementsAsMap() { MockHttpServletRequest request; Map customDepositFormElements; request = new MockHttpServletRequest(); request.addParameter("customDepositForm_customFormPopulated", "false"); customDepositFormElements = testInstance.getCustomDepositFormElementsAsMap(request); assertNull(customDepositFormElements); request = new MockHttpServletRequest(); request.addParameter("customDepositForm_customFormPopulated", (String)null); customDepositFormElements = testInstance.getCustomDepositFormElementsAsMap(request); assertNull(customDepositFormElements); request = new MockHttpServletRequest(); request.addParameter("customDepositForm_customFormPopulated", "true"); request.addParameter("customDepositForm_ParamX", "ValueX"); request.addParameter("customDepositForm_ParamY", "ValueY"); request.addParameter("someOther_ParamZ", "ValueZ"); customDepositFormElements = testInstance.getCustomDepositFormElementsAsMap(request); assertNotNull(customDepositFormElements); assertEquals(3, customDepositFormElements.size()); assertEquals("true", customDepositFormElements.get("customDepositForm_customFormPopulated")); assertEquals("ValueX", customDepositFormElements.get("customDepositForm_ParamX")); assertEquals("ValueY", customDepositFormElements.get("customDepositForm_ParamY")); assertNull(customDepositFormElements.get("someOther_ParamZ")); }