### Question:
ControlledProcessManagerServlet extends SlingAllMethodsServlet { Map<String, Object> convertRequestMap(RequestParameterMap requestParameterMap) { return requestParameterMap.entrySet().stream() .filter(entry -> !IGNORED_SERVLET_INPUTS.contains(entry.getKey())) .collect(Collectors.toMap( entry -> entry.getKey(), entry -> { final RequestParameter[] values = entry.getValue(); if (values.length == 1) { if (values[0].getFileName() != null) { return values[0]; } else { return values[0].getString(); } } else { return Arrays.stream(values).map(RequestParameter::getString).collect(Collectors.toList()); } } )); }    }### Answer:
@Test public void testConvertRequestMap() { Map<String, RequestParameter[]> params = new HashMap<>(); params.put("singleValue", getRequestParameter(null, "value")); params.put("multiValue", getRequestParameter(null, "value1", "value2", "value3")); params.put("fileUpload", getRequestParameter("filename", "value")); RequestParameterMap requestParameterMap = mock(RequestParameterMap.class); when(requestParameterMap.entrySet()).thenReturn(params.entrySet()); Map<String, Object> converted = servlet.convertRequestMap(requestParameterMap); assertEquals("value", converted.get("singleValue")); assertTrue("Should be request parameter", RequestParameter.class.isAssignableFrom(converted.get("fileUpload").getClass())); assertTrue("Should be list", List.class.isAssignableFrom(converted.get("multiValue").getClass())); List<String> multiValue = (List<String>) converted.get("multiValue"); assertArrayEquals(new String[]{"value1", "value2", "value3"}, multiValue.toArray()); }