ProjectController { @Secured(Roles.ROLE_USER) @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/project/{projectId}/pledges", method = RequestMethod.POST) public void pledgeProject(@PathVariable String projectId, @RequestBody @Valid Pledge pledge, Principal principal) { projectService.pledge(projectId, userByPrincipal(principal), pledge); }  @Secured({Roles.ROLE_USER}) @RequestMapping(value = "/projects", method = RequestMethod.GET) @JsonView(Project.ProjectSummaryView.class) List<Project> getProjects(Authentication auth); @Secured({Roles.ROLE_USER}) @RequestMapping(value = "/project/{projectId}", method = RequestMethod.GET) Project getProject(@PathVariable String projectId, Authentication auth); @Secured(Roles.ROLE_USER) @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/project", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) Project addProject(@RequestBody @Valid Project project, Principal principal); @Secured(Roles.ROLE_USER) @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/project/{projectId}/pledges", method = RequestMethod.POST) void pledgeProject(@PathVariable String projectId, @RequestBody @Valid Pledge pledge, Principal principal); @Secured(Roles.ROLE_ADMIN) @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/project/{projectId}/status", method = RequestMethod.PATCH) Project modifyProjectStatus(@PathVariable("projectId") String projectId, @RequestBody @Valid @NotNull ProjectStatusUpdate newStatus, Principal principal); @Secured(Roles.ROLE_USER) @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/project/{projectId}", method = RequestMethod.PUT) Project modifyProjectMasterdata(@PathVariable("projectId") String projectId, @RequestBody @Valid @NotNull Project modifiedProject, Principal principal); @Secured(Roles.ROLE_USER) @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/projects/{projectId}/likes", method = RequestMethod.POST) void likeProject(@PathVariable("projectId") String projectId, Principal principal); @Secured(Roles.ROLE_USER) @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/projects/{projectId}/likes", method = RequestMethod.DELETE) void unlikeProject(@PathVariable("projectId") String projectId, Principal principal); @Secured(Roles.ROLE_USER) @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/projects/{projectId}/attachments", method = RequestMethod.POST) Attachment addProjectAttachment(@PathVariable("projectId") String projectId, @RequestParam("file") MultipartFile file, Principal principal); @Secured({Roles.ROLE_TRUSTED_ANONYMOUS, Roles.ROLE_USER}) @RequestMapping(value = "/projects/{projectId}/attachments/{fileReference}", method = RequestMethod.GET) ResponseEntity<InputStreamResource> serveProjectAttachment(@PathVariable("projectId") String projectId, @PathVariable("fileReference") String fileReference); @Secured(Roles.ROLE_USER) @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/projects/{projectId}/attachments/{fileReference}", method = RequestMethod.DELETE) void deleteProjectAttachment(@PathVariable("projectId") String projectId, @PathVariable("fileReference") String fileReference, Principal principal);  }
@Test public void pledgeProject() throws Exception { final String projectId = "some_id"; final UserEntity user = userEntity(USER_EMAIL, USER_FIRST_NAME, USER_LAST_NAME, Roles.ROLE_USER); Pledge pledge = new Pledge(13); mockMvc.perform(post("/project/{projectId}/pledges", projectId) .principal(authentication(user)) .contentType(MediaType.APPLICATION_JSON) .content(mapper.writeValueAsString(pledge))) .andExpect(status().isCreated()); verify(projectService).pledge(projectId, user, pledge); }