### Question:
RequestUtils { public static String getQueryStringParameterValue(HttpServletRequest request, String parameterName) { MultiValueMap<String, String> valueMap = getQueryStringParameters(request); return ((valueMap == null) || !valueMap.containsKey(parameterName)) ? null : valueMap.getFirst(parameterName); }  static String getRemoteAddress(HttpServletRequest request); static String getRemoteAddress(); static void logRequestHeadersAndQueryParams(HttpServletRequest request, Logger logger); static MultiValueMap<String, String> getQueryStringParameters(HttpServletRequest request); static List<String> getQueryStringParameterValues(HttpServletRequest request, String parameterName); static String getQueryStringParameterValue(HttpServletRequest request, String parameterName);  }### Answer:
@Test public void testGetQueryStringParameterValue() { HttpServletRequest request = createMock(HttpServletRequest.class); expect(request.getQueryString()).andReturn(null).once(); expect(request.getQueryString()).andReturn("").once(); expect(request.getQueryString()).andReturn("p1=1").once(); expect(request.getQueryString()).andReturn("p1=1&p2=2").once(); expect(request.getQueryString()).andReturn("p1=1a&p2=2&p1=1b").once(); replayAll(); Assert.assertNull(RequestUtils.getQueryStringParameterValue(request, "p1")); Assert.assertNull(RequestUtils.getQueryStringParameterValue(request, "p1")); String parameterValue; parameterValue = RequestUtils.getQueryStringParameterValue(request, "p1"); Assert.assertEquals("1", parameterValue); parameterValue = RequestUtils.getQueryStringParameterValue(request, "p2"); Assert.assertEquals("2", parameterValue); parameterValue = RequestUtils.getQueryStringParameterValue(request, "p1"); Assert.assertEquals("1a", parameterValue); verifyAll(); }