Skip to content

Commit

Permalink
Added tests for issue #217
Browse files Browse the repository at this point in the history
  • Loading branch information
sapessi committed Dec 20, 2018
1 parent 00787d4 commit 2be72a5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ public void queryString_listParameter_expectCorrectLength() {
validateSingleValueModel(output, "3");
}

@Test
public void queryString_multiParam_expectCorrectValueCount()
throws IOException {
AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/multivalue-query-string", "GET")
.json()
.queryString("multiple", "first")
.queryString("multiple", "second")
.build();

AwsProxyResponse output = handler.proxy(request, lambdaContext);
assertEquals(200, output.getStatusCode());
MapResponseModel response = objectMapper.readValue(output.getBody(), MapResponseModel.class);

assertEquals(2, response.getValues().size());
assertTrue(response.getValues().containsKey("first"));
assertTrue(response.getValues().containsKey("second"));
}

@Test
public void dateHeader_notModified_expect304() {
AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/last-modified", "GET")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartResolver;
Expand Down Expand Up @@ -80,6 +81,15 @@ public MapResponseModel echoQueryString(HttpServletRequest request, @RequestPara
return queryStrings;
}

@RequestMapping(path = "/multivalue-query-string", method = RequestMethod.GET)
public MapResponseModel countMultivalueQueryParams(@RequestParam MultiValueMap<String, String> multipleParams) {
MapResponseModel out = new MapResponseModel();
for (String v : multipleParams.get("multiple")) {
out.addValue(v, "ok");
}
return out;
}

@RequestMapping(path = "/list-query-string", method = RequestMethod.GET)
public SingleValueModel echoListQueryString(@RequestParam(value="list") List<String> valueList) {
SingleValueModel value = new SingleValueModel();
Expand Down

0 comments on commit 2be72a5

Please sign in to comment.