ViolationsController { @ApiResponse(code = 202, message = "Violation successfully accepted!") @ResponseStatus(code = HttpStatus.ACCEPTED) @PostMapping(consumes = APPLICATION_JSON_VALUE) @PreAuthorize("#oauth2.hasScope('fullstop.violation.write')") public void createViolation(@Valid @RequestBody CreateViolation violation) { violationSink.put(violation); }  @ApiOperation( value = "violations", notes = "Get one violation", response = Violation.class ) @ApiResponses(value = {@ApiResponse(code = 200, message = "Violation")}) @RequestMapping(value = "/{id}", method = GET) Violation getViolation(
            @ApiParam(value = "Violation id")
            @PathVariable(value = "id")
            final Long id); @ApiOperation( value = "violations", notes = "Get all violations", response = Violation.class, responseContainer = "List" ) @ApiResponses(value = {@ApiResponse(code = 200, message = "List of all violations")}) @ApiImplicitParams({ @ApiImplicitParam(name = "from", dataType = "date-time", paramType = "query", value = "Include only violations that happened after this point in time. " + "Example: \"2015-05-21T10:24:47.788-02:00\""), @ApiImplicitParam(name = "to", dataType = "date-time", paramType = "query", value = "Include only violations that happened up to this point in time. " + "Example: \"2015-05-21T10:24:47.788-02:00\""), @ApiImplicitParam(name = "page", dataType = "integer", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "integer", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: \"property,[asc|desc]\". " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") }) @RequestMapping(method = GET) Page<Violation> violations(
            @ApiParam(value = "Include only violations in these accounts")
            @RequestParam(value = "accounts", required = false)
            final List<String> accounts,
            @ApiIgnore
            @RequestParam(value = "from", required = false)
            @DateTimeFormat(iso = DATE_TIME)
            DateTime from,
            @ApiIgnore
            @RequestParam(value = "to", required = false)
            @DateTimeFormat(iso = DATE_TIME)
            DateTime to,
            @ApiParam(value = "Include only violations after the one with this id")
            @RequestParam(value = "last-violation", required = false)
            final Long lastViolation,
            @ApiParam(value = "Include only violations where checked field equals this value (i.e. resolved violations)")
            @RequestParam(value = "checked", required = false, defaultValue = "false")
            final boolean checked,
            @ApiParam(value = "Include only violations with a certain severity")
            @RequestParam(value = "severity", required = false)
            final Integer severity,
            @ApiParam(value = "Include only violations with a certain priority")
            @RequestParam(value = "priority", required = false)
            final Integer priority,
            @ApiParam(value = "Include only violations that are audit relevant")
            @RequestParam(value = "audit-relevant", required = false)
            final Boolean auditRelevant,
            @ApiParam(value = "Include only violations with a certain type")
            @RequestParam(value = "type", required = false)
            final String type,
            @ApiParam(value = "Include only violations with a certain types")
            @RequestParam(value = "types", required = false)
            final List<String> types,
            @ApiParam(value = "Include only violations with a certain application name")
            @RequestParam(value = "application-ids", required = false)
            final List<String> applicationIds,
            @ApiParam(value = "Include only violations with a certain application version")
            @RequestParam(value = "application-version-ids", required = false)
            final List<String> applicationVersionIds,
            @ApiParam(value = "show also whitelisted vioaltions")
            @RequestParam(value = "whitelisted", required = false, defaultValue = "false")
            final boolean whitelisted,
            @ApiIgnore
            @PageableDefault(page = 0, size = 10, sort = "id", direction = ASC) final Pageable pageable); @ApiOperation( value = "Resolve and explain this violation", notes = "Resolve and explain violation", response = Void.class ) @ApiResponses(value = {@ApiResponse(code = 200, message = "Violation resolved successfully")}) @RequestMapping(value = "/{id}/resolution", method = POST) Violation resolveViolations(
            @ApiParam(value = "", required = true)
            @PathVariable("id")
            final Long id,
            @ApiParam(value = "", required = true)
            @RequestBody final String comment,
            @ApiIgnore @AuthenticationPrincipal(errorOnInvalidType = true) final String userId); @ApiResponse(code = 202, message = "Violation successfully accepted!") @ResponseStatus(code = HttpStatus.ACCEPTED) @PostMapping(consumes = APPLICATION_JSON_VALUE) @PreAuthorize("#oauth2.hasScope('fullstop.violation.write')") void createViolation(@Valid @RequestBody CreateViolation violation);  }
@Test public void testCreateViolation() throws Exception { this.mockMvc.perform(post("/api/violations") .contentType(APPLICATION_JSON) .content(objectMapper.writeValueAsBytes(createViolation))) .andExpect(status().isAccepted()); verify(violationSinkMock).put(eq(createViolation)); }