@Test @WithMockUser(username="tester", authorities={"CREATE_ACCESSTOKEN"}) public void testSavingAccessTokenWithoutDefaultValues() throws Exception { AccessToken recoverAt = new AccessToken(); recoverAt.setId(10L); Mockito.when(service.save(Mockito.any(AccessTokenPersist.class))).thenReturn(recoverAt); mockMvc.perform(MockMvcRequestBuilders.post(ConstantsPath.PATH_ACCESS_TOKENS, 10L) .content("{\"code\":\"!!@!##1212\",\"app\":{\"id\":10}, \"plans\": [{\"id\": 5}]}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(MockMvcResultMatchers.status().isCreated()); }
@ResponseBody @ApiOperation(value = "Save a new AccessToken") @PostMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_CREATE_ACCESSTOKEN) public ResponseEntity<?> save(@RequestBody @Valid AccessTokenPersist accessTokenPersist) { AccessToken accessToken = accessTokenService.save(accessTokenPersist); return ResponseEntity.created(URI.create(String.format("/%s/%s", "access-tokens", accessToken.getId().toString()))).build(); }
AccessTokenResource { @ResponseBody @ApiOperation(value = "Save a new AccessToken") @PostMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_CREATE_ACCESSTOKEN) public ResponseEntity<?> save(@RequestBody @Valid AccessTokenPersist accessTokenPersist) { AccessToken accessToken = accessTokenService.save(accessTokenPersist); return ResponseEntity.created(URI.create(String.format("/%s/%s", "access-tokens", accessToken.getId().toString()))).build(); } }
AccessTokenResource { @ResponseBody @ApiOperation(value = "Save a new AccessToken") @PostMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_CREATE_ACCESSTOKEN) public ResponseEntity<?> save(@RequestBody @Valid AccessTokenPersist accessTokenPersist) { AccessToken accessToken = accessTokenService.save(accessTokenPersist); return ResponseEntity.created(URI.create(String.format("/%s/%s", "access-tokens", accessToken.getId().toString()))).build(); }  }
AccessTokenResource { @ResponseBody @ApiOperation(value = "Save a new AccessToken") @PostMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_CREATE_ACCESSTOKEN) public ResponseEntity<?> save(@RequestBody @Valid AccessTokenPersist accessTokenPersist) { AccessToken accessToken = accessTokenService.save(accessTokenPersist); return ResponseEntity.created(URI.create(String.format("/%s/%s", "access-tokens", accessToken.getId().toString()))).build(); }  @ResponseBody @ApiOperation(value = "Find AccessToken by id", response = AccessToken.class) @GetMapping(value = "/{accessTokenId}") @PreAuthorize(ConstantsPrivilege.PRIVILEGE_READ_ACCESSTOKEN) ResponseEntity<?> findById(@PathVariable("accessTokenId") Long id); @ResponseBody @ApiOperation(value = "Find all AccessTokens", responseContainer = "List", response = AccessToken.class) @GetMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_READ_ACCESSTOKEN) ResponseEntity<?> findAll(@ModelAttribute AccessTokenRequest accessTokenRequest, @ModelAttribute PageableDTO pageableDTO); @ResponseBody @ApiOperation(value = "Save a new AccessToken") @PostMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_CREATE_ACCESSTOKEN) ResponseEntity<?> save(@RequestBody @Valid AccessTokenPersist accessTokenPersist); @ResponseBody @ApiOperation(value = "Update AccessToken") @PutMapping(value = "/{accessTokenId}") @PreAuthorize(ConstantsPrivilege.PRIVILEGE_UPDATE_ACCESSTOKEN) ResponseEntity<?> update(@PathVariable("accessTokenId") Long id, @RequestBody AccessTokenPersist accessTokenPersist); @ResponseBody @ApiOperation(value = "Delete AccessToken") @DeleteMapping(value = "/{accessTokenId}") @PreAuthorize(ConstantsPrivilege.PRIVILEGE_DELETE_ACCESSTOKEN) ResponseEntity<?> delete(@PathVariable("accessTokenId") Long id); }
AccessTokenResource { @ResponseBody @ApiOperation(value = "Save a new AccessToken") @PostMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_CREATE_ACCESSTOKEN) public ResponseEntity<?> save(@RequestBody @Valid AccessTokenPersist accessTokenPersist) { AccessToken accessToken = accessTokenService.save(accessTokenPersist); return ResponseEntity.created(URI.create(String.format("/%s/%s", "access-tokens", accessToken.getId().toString()))).build(); }  @ResponseBody @ApiOperation(value = "Find AccessToken by id", response = AccessToken.class) @GetMapping(value = "/{accessTokenId}") @PreAuthorize(ConstantsPrivilege.PRIVILEGE_READ_ACCESSTOKEN) ResponseEntity<?> findById(@PathVariable("accessTokenId") Long id); @ResponseBody @ApiOperation(value = "Find all AccessTokens", responseContainer = "List", response = AccessToken.class) @GetMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_READ_ACCESSTOKEN) ResponseEntity<?> findAll(@ModelAttribute AccessTokenRequest accessTokenRequest, @ModelAttribute PageableDTO pageableDTO); @ResponseBody @ApiOperation(value = "Save a new AccessToken") @PostMapping @PreAuthorize(ConstantsPrivilege.PRIVILEGE_CREATE_ACCESSTOKEN) ResponseEntity<?> save(@RequestBody @Valid AccessTokenPersist accessTokenPersist); @ResponseBody @ApiOperation(value = "Update AccessToken") @PutMapping(value = "/{accessTokenId}") @PreAuthorize(ConstantsPrivilege.PRIVILEGE_UPDATE_ACCESSTOKEN) ResponseEntity<?> update(@PathVariable("accessTokenId") Long id, @RequestBody AccessTokenPersist accessTokenPersist); @ResponseBody @ApiOperation(value = "Delete AccessToken") @DeleteMapping(value = "/{accessTokenId}") @PreAuthorize(ConstantsPrivilege.PRIVILEGE_DELETE_ACCESSTOKEN) ResponseEntity<?> delete(@PathVariable("accessTokenId") Long id);  }