title: Mock server Request
body: <p>Im using spring, and in my controller method im expecting a query paramether </p>
  
  <pre><code>@RequestMapping(method = RequestMethod.GET)
      public MyClass myMethod(
              @ApiParam(defaultValue = "some string", value = "some text") @RequestParam("myParam") MyClass2 myParam) {
              //do something
          }
  </code></pre>
  
  <p>now in JUnit test i want to call this method, for this i have prepeared a request, however i can not find a proper way to <code>setQueryString()</code></p>
  
  <pre><code>MockHttpServletRequest request = new MockHttpServletRequest();
  request.setRequestURI("/pathToMyMethod");
  request.setQueryString(new MyClass2().toString());
  </code></pre>
  
  <p>Constructing a new object and calling <code>toString()</code> on it does not work.
  (calling empty constructor is creating object with random values)</p>
  
  <p>Failure trace:
  <code>org.springframework.web.bind.MissingServletRequestParameterException: Required MyClass2 parameter 'myParam' is not present.</code></p>
  
  <p>How to create such request properly?</p>