@Test public void policyViolationReasonTest() throws Exception { when(complianceService.getPolicyViolationDetailsByIssueId(anyString(),anyString())).thenReturn(new PolicyViolationDetails()); assertThat(complianceController.policyViolationReason("ag","domain"), is(notNullValue())); assertThat(complianceController.policyViolationReason("",""), is(notNullValue())); when(complianceService.getPolicyViolationDetailsByIssueId(anyString(),anyString())).thenThrow(new ServiceException()); when(complianceService.formatException(anyObject())).thenReturn(ResponseUtils.buildFailureResponse(new ServiceException())); ResponseEntity<Object> responseObj = complianceController.policyViolationReason("ag","domain"); assertTrue(responseObj.getStatusCode() == HttpStatus.EXPECTATION_FAILED); }
@RequestMapping(path = "/v1/policyViolationReason", method = RequestMethod.GET) public ResponseEntity<Object> policyViolationReason(@RequestParam("ag") String assetgroup, @RequestParam(name = "issueId") String issueId) { if (Strings.isNullOrEmpty(assetgroup) && Strings.isNullOrEmpty(issueId)) { return ResponseUtils.buildFailureResponse(new Exception("AssetGroup/IssueId is Mandatory")); } PolicyViolationDetails response = null; try { response = complianceService.getPolicyViolationDetailsByIssueId(assetgroup, issueId); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }
ComplianceController implements Constants { @RequestMapping(path = "/v1/policyViolationReason", method = RequestMethod.GET) public ResponseEntity<Object> policyViolationReason(@RequestParam("ag") String assetgroup, @RequestParam(name = "issueId") String issueId) { if (Strings.isNullOrEmpty(assetgroup) && Strings.isNullOrEmpty(issueId)) { return ResponseUtils.buildFailureResponse(new Exception("AssetGroup/IssueId is Mandatory")); } PolicyViolationDetails response = null; try { response = complianceService.getPolicyViolationDetailsByIssueId(assetgroup, issueId); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); } }
ComplianceController implements Constants { @RequestMapping(path = "/v1/policyViolationReason", method = RequestMethod.GET) public ResponseEntity<Object> policyViolationReason(@RequestParam("ag") String assetgroup, @RequestParam(name = "issueId") String issueId) { if (Strings.isNullOrEmpty(assetgroup) && Strings.isNullOrEmpty(issueId)) { return ResponseUtils.buildFailureResponse(new Exception("AssetGroup/IssueId is Mandatory")); } PolicyViolationDetails response = null; try { response = complianceService.getPolicyViolationDetailsByIssueId(assetgroup, issueId); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  }
ComplianceController implements Constants { @RequestMapping(path = "/v1/policyViolationReason", method = RequestMethod.GET) public ResponseEntity<Object> policyViolationReason(@RequestParam("ag") String assetgroup, @RequestParam(name = "issueId") String issueId) { if (Strings.isNullOrEmpty(assetgroup) && Strings.isNullOrEmpty(issueId)) { return ResponseUtils.buildFailureResponse(new Exception("AssetGroup/IssueId is Mandatory")); } PolicyViolationDetails response = null; try { response = complianceService.getPolicyViolationDetailsByIssueId(assetgroup, issueId); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/issues", method = RequestMethod.POST) @ResponseBody ResponseEntity<Object> getIssues(@RequestBody(required = false) Request request); @RequestMapping(path = "/v1/issues/count", method = RequestMethod.GET) ResponseEntity<Object> getIssuesCount(@RequestParam("ag") String assetGroup,
            @RequestParam("domain") String domain, @RequestParam(name = "ruleId", required = false) String ruleId); @RequestMapping(path = "/v1/issues/distribution", method = RequestMethod.GET) ResponseEntity<Object> getDistribution(@RequestParam("ag") String assetGroup,
            @RequestParam(name = "domain", required = false) String domain); @RequestMapping(path = "/v1/tagging", method = RequestMethod.GET) ResponseEntity<Object> getTagging(@RequestParam("ag") String assetGroup,
            @RequestParam(name = "targettype", required = false) String targetType); @RequestMapping(path = "/v1/certificates", method = RequestMethod.GET) ResponseEntity<Object> getCertificates(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/patching", method = RequestMethod.GET) ResponseEntity<Object> getPatching(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/recommendations", method = RequestMethod.GET) ResponseEntity<Object> getRecommendations(@RequestParam("ag") String assetGroup,
            @RequestParam(name = "targettype", required = false) String targetType); @RequestMapping(path = "/v1/issueauditlog", method = RequestMethod.POST) ResponseEntity<Object> getIssueAudit(@RequestBody IssueAuditLogRequest request); @RequestMapping(path = "/v1/resourcedetails", method = RequestMethod.GET) ResponseEntity<Object> getResourceDetails(@RequestParam("ag") String assetGroup,
            @RequestParam("resourceId") String resourceId); @ApiOperation(httpMethod = "PUT", value = "Close Issues by Rule Details") @RequestMapping(path = "/v1/issues/close-by-rule-id", method = RequestMethod.PUT) @ResponseBody ResponseEntity<Object> closeIssues(
            @ApiParam(value = "Provide valid Rule Details ", required = true) @RequestBody(required = true) RuleDetails ruleDetails); @ApiOperation(httpMethod = "POST", value = "Adding issue exception to the corresponding target type") @RequestMapping(path = "/v1/issues/add-exception", method = RequestMethod.POST) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Added Issue Exception"), @ApiResponse(code = 401, message = "You are not authorized to Add Issue Exception"), @ApiResponse(code = 403, message = "Add Issue Exception is forbidden") }) @ResponseBody ResponseEntity<Object> addIssueException(
            @ApiParam(value = "Provide Issue Exception Details", required = true) @RequestBody(required = true) IssueResponse issueException); @ApiOperation(httpMethod = "POST", value = "Revoking issue exception to the corresponding target type") @RequestMapping(path = "/v1/issues/revoke-exception", method = RequestMethod.POST) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Revoked Issue Exception"), @ApiResponse(code = 401, message = "You are not authorized to Revoke Issue Exception"), @ApiResponse(code = 403, message = "Revoke IssueException is forbidden") }) @ResponseBody ResponseEntity<Object> revokeIssueException(
            @ApiParam(value = "Provide Issue Id", required = true) @RequestParam(required = true) String issueId); @RequestMapping(path = "/v1/noncompliancepolicy", method = RequestMethod.POST) // @Cacheable(cacheNames="compliance",unless="#result.status==200") // commenting to performance after refacoting // @Cacheable(cacheNames="compliance",key="#request.key") ResponseEntity<Object> getNonCompliancePolicyByRule(@RequestBody(required = false) Request request); @RequestMapping(path = "/v1/policydetailsbyapplication", method = RequestMethod.GET) // @Cacheable(cacheNames="compliance",unless="#result.status==200") ResponseEntity<Object> getPolicydetailsbyApplication(@RequestParam("ag") String assetGroup,
            @RequestParam("ruleId") String ruleId,
            @RequestParam(name = "searchText", required = false) String searchText); @RequestMapping(path = "/v1/policydetailsbyenvironment", method = RequestMethod.GET) ResponseEntity<Object> getpolicydetailsbyEnvironment(@RequestParam("ag") String assetGroup,
            @RequestParam("application") String application, @RequestParam("ruleId") String ruleId,
            @RequestParam(name = "searchText", required = false) String searchText); @RequestMapping(path = "/v1/policydescription", method = RequestMethod.GET) ResponseEntity<Object> getPolicyDescription(@RequestParam("ruleId") String ruleId); @RequestMapping(path = "/v1/kernelcompliancebyinstanceid", method = RequestMethod.GET) ResponseEntity<Object> getKernelComplianceByInstanceId(@RequestParam("instanceId") String instanceId); @ApiOperation(httpMethod = "PUT", value = "Update Kernel Version by InstanceId") @RequestMapping(path = "/v1/update-kernel-version", method = RequestMethod.PUT) @ResponseBody ResponseEntity<Object> updateKernelVersion(
            @ApiParam(value = "Provide valid Rule Details ", required = true) @RequestBody(required = true) KernelVersion kernelVersion); @RequestMapping(path = "/v1/overallcompliance", method = RequestMethod.GET) ResponseEntity<Object> getOverallCompliance(@RequestParam("ag") String assetGroup,
            @RequestParam(name = "domain") String domain); @RequestMapping(path = "/v1/targetType", method = RequestMethod.GET) ResponseEntity<Object> getTargetType(@RequestParam("ag") String assetgroup,
            @RequestParam(name = "domain", required = false) String domain); @RequestMapping(path = "/v1/policyViolationReason", method = RequestMethod.GET) ResponseEntity<Object> policyViolationReason(@RequestParam("ag") String assetgroup,
            @RequestParam(name = "issueId") String issueId); @RequestMapping(path = "/v1/get-current-kernel-versions", method = RequestMethod.GET) ResponseEntity<Object> getCurrentKernelVersions(); @ApiOperation(httpMethod = "POST", value = "Adding issue exception to the corresponding target type") @RequestMapping(path = "/v2/issue/add-exception", method = RequestMethod.POST) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Added Issue Exception"), @ApiResponse(code = 401, message = "You are not authorized to Add Issue Exception"), @ApiResponse(code = 403, message = "Add Issue Exception is forbidden") }) @ResponseBody ResponseEntity<Object> addIssuesException(
            @ApiParam(value = "Provide Issue Exception Details", required = true) @RequestBody(required = true) IssuesException issuesException); @ApiOperation(httpMethod = "POST", value = "Revoking issue exception to the corresponding target type") @RequestMapping(path = "/v2/issue/revoke-exception", method = RequestMethod.POST) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Revoked Issue Exception"), @ApiResponse(code = 401, message = "You are not authorized to Revoke Issue Exception"), @ApiResponse(code = 403, message = "Revoke IssueException is forbidden") }) @ResponseBody ResponseEntity<Object> revokeIssuesException(
            @ApiParam(value = "Provide Issue Id", required = true) @RequestBody(required = true) RevokeIssuesException revokeIssuesException); }
ComplianceController implements Constants { @RequestMapping(path = "/v1/policyViolationReason", method = RequestMethod.GET) public ResponseEntity<Object> policyViolationReason(@RequestParam("ag") String assetgroup, @RequestParam(name = "issueId") String issueId) { if (Strings.isNullOrEmpty(assetgroup) && Strings.isNullOrEmpty(issueId)) { return ResponseUtils.buildFailureResponse(new Exception("AssetGroup/IssueId is Mandatory")); } PolicyViolationDetails response = null; try { response = complianceService.getPolicyViolationDetailsByIssueId(assetgroup, issueId); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/issues", method = RequestMethod.POST) @ResponseBody ResponseEntity<Object> getIssues(@RequestBody(required = false) Request request); @RequestMapping(path = "/v1/issues/count", method = RequestMethod.GET) ResponseEntity<Object> getIssuesCount(@RequestParam("ag") String assetGroup,
            @RequestParam("domain") String domain, @RequestParam(name = "ruleId", required = false) String ruleId); @RequestMapping(path = "/v1/issues/distribution", method = RequestMethod.GET) ResponseEntity<Object> getDistribution(@RequestParam("ag") String assetGroup,
            @RequestParam(name = "domain", required = false) String domain); @RequestMapping(path = "/v1/tagging", method = RequestMethod.GET) ResponseEntity<Object> getTagging(@RequestParam("ag") String assetGroup,
            @RequestParam(name = "targettype", required = false) String targetType); @RequestMapping(path = "/v1/certificates", method = RequestMethod.GET) ResponseEntity<Object> getCertificates(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/patching", method = RequestMethod.GET) ResponseEntity<Object> getPatching(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/recommendations", method = RequestMethod.GET) ResponseEntity<Object> getRecommendations(@RequestParam("ag") String assetGroup,
            @RequestParam(name = "targettype", required = false) String targetType); @RequestMapping(path = "/v1/issueauditlog", method = RequestMethod.POST) ResponseEntity<Object> getIssueAudit(@RequestBody IssueAuditLogRequest request); @RequestMapping(path = "/v1/resourcedetails", method = RequestMethod.GET) ResponseEntity<Object> getResourceDetails(@RequestParam("ag") String assetGroup,
            @RequestParam("resourceId") String resourceId); @ApiOperation(httpMethod = "PUT", value = "Close Issues by Rule Details") @RequestMapping(path = "/v1/issues/close-by-rule-id", method = RequestMethod.PUT) @ResponseBody ResponseEntity<Object> closeIssues(
            @ApiParam(value = "Provide valid Rule Details ", required = true) @RequestBody(required = true) RuleDetails ruleDetails); @ApiOperation(httpMethod = "POST", value = "Adding issue exception to the corresponding target type") @RequestMapping(path = "/v1/issues/add-exception", method = RequestMethod.POST) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Added Issue Exception"), @ApiResponse(code = 401, message = "You are not authorized to Add Issue Exception"), @ApiResponse(code = 403, message = "Add Issue Exception is forbidden") }) @ResponseBody ResponseEntity<Object> addIssueException(
            @ApiParam(value = "Provide Issue Exception Details", required = true) @RequestBody(required = true) IssueResponse issueException); @ApiOperation(httpMethod = "POST", value = "Revoking issue exception to the corresponding target type") @RequestMapping(path = "/v1/issues/revoke-exception", method = RequestMethod.POST) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Revoked Issue Exception"), @ApiResponse(code = 401, message = "You are not authorized to Revoke Issue Exception"), @ApiResponse(code = 403, message = "Revoke IssueException is forbidden") }) @ResponseBody ResponseEntity<Object> revokeIssueException(
            @ApiParam(value = "Provide Issue Id", required = true) @RequestParam(required = true) String issueId); @RequestMapping(path = "/v1/noncompliancepolicy", method = RequestMethod.POST) // @Cacheable(cacheNames="compliance",unless="#result.status==200") // commenting to performance after refacoting // @Cacheable(cacheNames="compliance",key="#request.key") ResponseEntity<Object> getNonCompliancePolicyByRule(@RequestBody(required = false) Request request); @RequestMapping(path = "/v1/policydetailsbyapplication", method = RequestMethod.GET) // @Cacheable(cacheNames="compliance",unless="#result.status==200") ResponseEntity<Object> getPolicydetailsbyApplication(@RequestParam("ag") String assetGroup,
            @RequestParam("ruleId") String ruleId,
            @RequestParam(name = "searchText", required = false) String searchText); @RequestMapping(path = "/v1/policydetailsbyenvironment", method = RequestMethod.GET) ResponseEntity<Object> getpolicydetailsbyEnvironment(@RequestParam("ag") String assetGroup,
            @RequestParam("application") String application, @RequestParam("ruleId") String ruleId,
            @RequestParam(name = "searchText", required = false) String searchText); @RequestMapping(path = "/v1/policydescription", method = RequestMethod.GET) ResponseEntity<Object> getPolicyDescription(@RequestParam("ruleId") String ruleId); @RequestMapping(path = "/v1/kernelcompliancebyinstanceid", method = RequestMethod.GET) ResponseEntity<Object> getKernelComplianceByInstanceId(@RequestParam("instanceId") String instanceId); @ApiOperation(httpMethod = "PUT", value = "Update Kernel Version by InstanceId") @RequestMapping(path = "/v1/update-kernel-version", method = RequestMethod.PUT) @ResponseBody ResponseEntity<Object> updateKernelVersion(
            @ApiParam(value = "Provide valid Rule Details ", required = true) @RequestBody(required = true) KernelVersion kernelVersion); @RequestMapping(path = "/v1/overallcompliance", method = RequestMethod.GET) ResponseEntity<Object> getOverallCompliance(@RequestParam("ag") String assetGroup,
            @RequestParam(name = "domain") String domain); @RequestMapping(path = "/v1/targetType", method = RequestMethod.GET) ResponseEntity<Object> getTargetType(@RequestParam("ag") String assetgroup,
            @RequestParam(name = "domain", required = false) String domain); @RequestMapping(path = "/v1/policyViolationReason", method = RequestMethod.GET) ResponseEntity<Object> policyViolationReason(@RequestParam("ag") String assetgroup,
            @RequestParam(name = "issueId") String issueId); @RequestMapping(path = "/v1/get-current-kernel-versions", method = RequestMethod.GET) ResponseEntity<Object> getCurrentKernelVersions(); @ApiOperation(httpMethod = "POST", value = "Adding issue exception to the corresponding target type") @RequestMapping(path = "/v2/issue/add-exception", method = RequestMethod.POST) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Added Issue Exception"), @ApiResponse(code = 401, message = "You are not authorized to Add Issue Exception"), @ApiResponse(code = 403, message = "Add Issue Exception is forbidden") }) @ResponseBody ResponseEntity<Object> addIssuesException(
            @ApiParam(value = "Provide Issue Exception Details", required = true) @RequestBody(required = true) IssuesException issuesException); @ApiOperation(httpMethod = "POST", value = "Revoking issue exception to the corresponding target type") @RequestMapping(path = "/v2/issue/revoke-exception", method = RequestMethod.POST) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Revoked Issue Exception"), @ApiResponse(code = 401, message = "You are not authorized to Revoke Issue Exception"), @ApiResponse(code = 403, message = "Revoke IssueException is forbidden") }) @ResponseBody ResponseEntity<Object> revokeIssuesException(
            @ApiParam(value = "Provide Issue Id", required = true) @RequestBody(required = true) RevokeIssuesException revokeIssuesException);  }