title: How do I validate that the @RequestParams are not empty?
body: <p>I have a calculator service that gets the operation type, num1 and num2 from the user. I need to validate that the user actually inputs these values and doesn't just leave it blank.    </p>
  
  <pre><code>@RequestMapping(value = "/calculate")
  @ResponseBody
  public CalculationResult calculate(@RequestParam(name = "op") String operation, @RequestParam(name = "num1") Double num1, @RequestParam(name = "num2") Double num2) {
      System.out.print("Operation:" + operation);
      Double calculate = calculatorService.calculate(operation, num1, num2);
      return new CalculationResult(calculate);
  }
  </code></pre>
  
  <p>I have an Integration test that I need to  make pass as it is currently failing with error:</p>
  
  <blockquote>
    <p>{\"timestamp\":1488875777084,\"status\":400,\"error\":\"Bad
    Request\",\"exception\":\"org.springframework.web.method.annotation.MethodArgumentTypeMismatchException\",\"message\":\"Failed
    to convert value of type 'java.lang.String' to required type
    'java.lang.Double';</p>
  </blockquote>
  
  <p>Below is my Test Case:</p>
  
  <pre><code>@Test
  public void validates_all_parameters_are_set() throws Exception {
      ResponseEntity&lt;String&gt; response = template.getForEntity( "/calculate?op=&amp;num1=&amp;num2=",
              String.class);
      assertThat(response.getStatusCode(), equalTo(HttpStatus.BAD_REQUEST));
      assertThat(response.getBody(), equalTo("{\"error\":\"At least one parameter is invalid or not supplied\"}"));
  }
  </code></pre>
  
  <p>I don't know how to validate this.</p>