title: Spring MockMvc - request parameter list
body: <p>I'm trying to test a couple of controller endpoints with MockMvc and I'm having a bit of trouble (be kind, I'm new...). The simple endpoint that consumes a string as it's parameter works fine, but the slightly more complicated endpoint that consumes a list of strings is not happy and throws an exception; can anybody point out what I'm doing wrong?</p>
  
  <pre><code>@RestController
  @RequestMapping("/bleh")
  public class Controller
  {
      @Autowired
      private DataService dataService
  
      @RequestMapping(value = "/simple", method = RequestMethod.GET)
      public String simple(String name) 
      { 
          return dataService.getSomeData(name) 
      }
  
      @RequestMapping(value = "/complicated", method = RequestMethod.GET)
      public String complex(List&lt;String&gt; names)
      { 
          return dataService.getSomeOtherData(names) 
      }
  }
  </code></pre>
  
  <p>-</p>
  
  <pre><code>@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  class HealthControllerTests extends Specification
  {
      def dataServiceMock;
      def testController;
      def mockMvc;
  
  
      def setup(){
          dataServiceMock = Mock(DataService)
          dataServiceMock.getSomeData &gt;&gt; "blaah"
          testController = new Controller(dataService: dataServiceMock)
          mockMvc = MockMvcBuilders.standaloneSetup(testController).build();
      }
  
      def "working test"
          when:
          def response = MockMvc.perform(get("/simple").param("name", "tim"))
                  .andReturn()
                  .getResponse();
  
          then:
          response.status == OK.value();
          response.contentAsString == "blaah"
  
      def "unhappy test"
          when:
          def response = MockMvc.perform(get("/complicated").param("names", new ArrayList&lt;&gt;()))
              .andReturn()
              .getResponse();
  
          then:
          response.status == OK.value()
  
  
  }
  </code></pre>
  
  <p>throws this:</p>
  
  <pre><code>No signature of method: org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder.param() is applicable for argument types: (java.lang.String, java.util.ArrayList) values: [names, []]. Possible solutions: param(java.lang.String, [Ljava.lang.String;), params(org.springframework.util.MultiValueMap), wait(), grep(), any(), putAt(java.lang.String, java.lang.Object)])
  </code></pre>