HttpRequest { public String getParameter(String name) { if (parameters.get(name) == null) { return null; } return parameters.get(name).get(0); } HttpRequest(Map<String, List<String>> parameters); String getParameter(String name);  }
@Test public void should_return_parameter_value() { Map<String, List<String>> rawParams = Collections.singletonMap("myParam", Collections.singletonList("123")); HttpRequest httpRequest = new HttpRequest(rawParams); String myParamValue = httpRequest.getParameter("myParam"); assertThat(myParamValue).isEqualTo("123"); }
@Test public void should_return_null_when_no_parameter__with_given_name() { Map<String, List<String>> rawParams = Collections.singletonMap("myParam", Collections.singletonList("123")); HttpRequest httpRequest = new HttpRequest(rawParams); String myParamValue = httpRequest.getParameter("myParam2"); assertThat(myParamValue).isNull(); }