title: Custom annotation isn't validating method parameter
body: <p>I created a custom annotation</p>
  
  <pre><code>@Documented
  @Constraint(validatedBy = CheckGranularityValidator.class)
  @Target( { ElementType.PARAMETER} )
  @Retention(RetentionPolicy.RUNTIME)
  public @interface CheckGranularity {
      String message() default "Duration has to be a multiple of granularity";
      Class&lt;?&gt;[] groups() default {};
      Class&lt;? extends Payload&gt;[] payload() default {};
  }
  </code></pre>
  
  <p>With a validator like so</p>
  
  <pre><code>public class CheckGranularityValidator implements ConstraintValidator&lt;CheckGranularity, AssetCostsRequest&gt; {
  
      @Override
      public void initialize(final CheckGranularity constraintAnnotation) {
  
      }
  
      @Override
      public boolean isValid(final AssetCostsRequest value, final ConstraintValidatorContext context) {
          return value.getRange().getDuration() % value.getGranularity() == 0;
      }
  }
  </code></pre>
  
  <p>I tried using it in my RestController</p>
  
  <pre><code>@RestController
  public class CalcApiController extends CalcApi {
  
  @Override
  public ResponseEntity&lt;String&gt; calcProfitability(@Valid @CheckGranularity @RequestBody final AssetCostsRequest assetCostsRequest) {
      return ResponseEntity.ok("Works");
  }
  </code></pre>
  
  <p>I tried using this annotation by writing a test:</p>
  
  <pre><code>@Test
  public void calcTest() {
      final AssetCostsRequest request = new AssetCostsRequest()
          .setRange(new TimeRange(100L, 200L))
          .setGranularity(26L);
  
      given()
          .contentType(ContentType.JSON)
          .body(request)
      .when()
          .post("/calc")
      .then()
          .statusCode(HttpStatus.SC_BAD_REQUEST);
  }
  </code></pre>
  
  <p>Relevant part of AssetCostsRequest:</p>
  
  <pre><code>public class AssetCostsRequest {
  
      @JsonProperty
      @NotNull
      private TimeRange range;
  
      @JsonProperty
      @NotNull
      private Long granularity = 30L;
  
      ...getters &amp; setters
  }
  </code></pre>
  
  <p>Test method returns with 200. When I try to set a breakpoint in <code>isValid</code> method, it isn't hit when I run the test. I tried changing order of annotations, getting rid of <code>@Valid</code>, changing <code>@Target</code> in <code>CheckGranularity</code> class, nothing helped. I'm using RestAssured for testing.</p>
  
  <p>How do I make it, so my annotation is properly validating a parameter?</p>