@Test public void getAllPolicyIdsTest() throws Exception { when(policyService.getAllPolicyIds()).thenReturn(getAllPolicyIdsResponse()); mockMvc.perform(get("/policy/list-ids")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.data[0]", is("policyId123"))) .andExpect(jsonPath("$.message", is("success"))); }
@ApiOperation(httpMethod = "GET", value = "API to get all policy ids", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-ids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllPolicyIds() { try { return ResponseUtils.buildSucessResponse(policyService.getAllPolicyIds()); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }
PolicyController { @ApiOperation(httpMethod = "GET", value = "API to get all policy ids", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-ids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllPolicyIds() { try { return ResponseUtils.buildSucessResponse(policyService.getAllPolicyIds()); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } } }
PolicyController { @ApiOperation(httpMethod = "GET", value = "API to get all policy ids", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-ids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllPolicyIds() { try { return ResponseUtils.buildSucessResponse(policyService.getAllPolicyIds()); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }  }
PolicyController { @ApiOperation(httpMethod = "GET", value = "API to get all policy ids", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-ids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllPolicyIds() { try { return ResponseUtils.buildSucessResponse(policyService.getAllPolicyIds()); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }  @ApiOperation(httpMethod = "GET", value = "API to get all policies", response = Page.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getPolicies(
			@ApiParam(value = "provide valid page number", required = true) @RequestParam("page") Integer page,
			@ApiParam(value = "provide valid page size", required = true) @RequestParam("size") Integer size,
			@ApiParam(value = "provide valid search term", required = false) @RequestParam(defaultValue="", name = "searchTerm", required = false) String searchTerm); @ApiOperation(httpMethod = "GET", value = "API to get policy by id", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/details-by-id", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getRulesById(
			@ApiParam(value = "provide valid policy id", required = true) @RequestParam("policyId") String policyId); @ApiOperation(httpMethod = "GET", value = "API to get all policy ids", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/list-ids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllPolicyIds(); @ApiOperation(httpMethod = "POST", value = "API to update existing policy", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> updatePolicies(
			@ApiParam(value = "provide valid policy details", required = true) @RequestBody(required = true) UpdatePolicyDetails policyDetails); @ApiOperation(httpMethod = "POST", value = "API to create new policy", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> createPolicies(
			@ApiParam(value = "provide valid policy details", required = true) @RequestBody(required = true) CreatePolicyDetails policyDetails); }
PolicyController { @ApiOperation(httpMethod = "GET", value = "API to get all policy ids", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-ids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllPolicyIds() { try { return ResponseUtils.buildSucessResponse(policyService.getAllPolicyIds()); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }  @ApiOperation(httpMethod = "GET", value = "API to get all policies", response = Page.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getPolicies(
			@ApiParam(value = "provide valid page number", required = true) @RequestParam("page") Integer page,
			@ApiParam(value = "provide valid page size", required = true) @RequestParam("size") Integer size,
			@ApiParam(value = "provide valid search term", required = false) @RequestParam(defaultValue="", name = "searchTerm", required = false) String searchTerm); @ApiOperation(httpMethod = "GET", value = "API to get policy by id", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/details-by-id", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getRulesById(
			@ApiParam(value = "provide valid policy id", required = true) @RequestParam("policyId") String policyId); @ApiOperation(httpMethod = "GET", value = "API to get all policy ids", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/list-ids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllPolicyIds(); @ApiOperation(httpMethod = "POST", value = "API to update existing policy", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> updatePolicies(
			@ApiParam(value = "provide valid policy details", required = true) @RequestBody(required = true) UpdatePolicyDetails policyDetails); @ApiOperation(httpMethod = "POST", value = "API to create new policy", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) //@PreAuthorize("@securityService.hasPermission(authentication)") @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> createPolicies(
			@ApiParam(value = "provide valid policy details", required = true) @RequestBody(required = true) CreatePolicyDetails policyDetails);  }