@Test public void getFiltersTest() throws Exception { when(filterService.getFilters(anyInt(),anyString())).thenReturn(CommonTestUtil.getListMapObject()); assertThat(filterController.getFilters(1,"domain"), is(notNullValue())); assertThat(filterController.getFilters(0,""), is(notNullValue())); when(filterService.getFilters(anyInt(),anyString())).thenThrow(new ServiceException()); when(complianceService.formatException(anyObject())).thenReturn(ResponseUtils.buildFailureResponse(new ServiceException())); ResponseEntity<Object> responseObj = filterController.getFilters(1,"domain"); assertTrue(responseObj.getStatusCode() == HttpStatus.EXPECTATION_FAILED); }
@RequestMapping(path = "/v1/filters", method = RequestMethod.GET) public ResponseEntity<Object> getFilters( @ApiParam(value = "Provide filter 1-issue,2-vulnerability,3-asset,4-compliance", required = false) @RequestParam("filterId") int filterId, @RequestParam(name = "domain", required = false) String domain) { if (filterId <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("Object filterId is Mandatory")); } ResponseData response = null; try { response = new ResponseData(filterService.getFilters(filterId, domain)); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }
FilterController implements Constants { @RequestMapping(path = "/v1/filters", method = RequestMethod.GET) public ResponseEntity<Object> getFilters( @ApiParam(value = "Provide filter 1-issue,2-vulnerability,3-asset,4-compliance", required = false) @RequestParam("filterId") int filterId, @RequestParam(name = "domain", required = false) String domain) { if (filterId <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("Object filterId is Mandatory")); } ResponseData response = null; try { response = new ResponseData(filterService.getFilters(filterId, domain)); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); } }
FilterController implements Constants { @RequestMapping(path = "/v1/filters", method = RequestMethod.GET) public ResponseEntity<Object> getFilters( @ApiParam(value = "Provide filter 1-issue,2-vulnerability,3-asset,4-compliance", required = false) @RequestParam("filterId") int filterId, @RequestParam(name = "domain", required = false) String domain) { if (filterId <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("Object filterId is Mandatory")); } ResponseData response = null; try { response = new ResponseData(filterService.getFilters(filterId, domain)); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  }
FilterController implements Constants { @RequestMapping(path = "/v1/filters", method = RequestMethod.GET) public ResponseEntity<Object> getFilters( @ApiParam(value = "Provide filter 1-issue,2-vulnerability,3-asset,4-compliance", required = false) @RequestParam("filterId") int filterId, @RequestParam(name = "domain", required = false) String domain) { if (filterId <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("Object filterId is Mandatory")); } ResponseData response = null; try { response = new ResponseData(filterService.getFilters(filterId, domain)); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/filters", method = RequestMethod.GET) ResponseEntity<Object> getFilters(
            @ApiParam(value = "Provide filter 1-issue,2-vulnerability,3-asset,4-compliance", required = false) @RequestParam("filterId") int filterId,
            @RequestParam(name = "domain", required = false) String domain); @RequestMapping(path = "/v1/filters/policies", method = RequestMethod.GET) ResponseEntity<Object> getPolicies(@RequestParam("ag") String assetGroup,
            @RequestParam("domain") String domain); @RequestMapping(path = "/v1/filters/regions", method = RequestMethod.GET) ResponseEntity<Object> getRegions(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/filters/accounts", method = RequestMethod.GET) ResponseEntity<Object> getAccounts(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/filters/rules", method = RequestMethod.GET) ResponseEntity<Object> getRules(@RequestParam("ag") String assetGroup, @RequestParam("domain") String domain); @RequestMapping(path = "/v1/filters/application", method = RequestMethod.GET) ResponseEntity<Object> getListOfApplications(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "domain", required = false) String domain); @RequestMapping(path = "/v1/filters/environment", method = RequestMethod.GET) ResponseEntity<Object> getListOfEnvironments(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "application", required = false) String application,
            @RequestParam(name = "domain", required = false) String domain); @GetMapping(value = "/v1/filters/targettype") ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "domain", required = false) String domain); }
FilterController implements Constants { @RequestMapping(path = "/v1/filters", method = RequestMethod.GET) public ResponseEntity<Object> getFilters( @ApiParam(value = "Provide filter 1-issue,2-vulnerability,3-asset,4-compliance", required = false) @RequestParam("filterId") int filterId, @RequestParam(name = "domain", required = false) String domain) { if (filterId <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("Object filterId is Mandatory")); } ResponseData response = null; try { response = new ResponseData(filterService.getFilters(filterId, domain)); } catch (ServiceException e) { return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/filters", method = RequestMethod.GET) ResponseEntity<Object> getFilters(
            @ApiParam(value = "Provide filter 1-issue,2-vulnerability,3-asset,4-compliance", required = false) @RequestParam("filterId") int filterId,
            @RequestParam(name = "domain", required = false) String domain); @RequestMapping(path = "/v1/filters/policies", method = RequestMethod.GET) ResponseEntity<Object> getPolicies(@RequestParam("ag") String assetGroup,
            @RequestParam("domain") String domain); @RequestMapping(path = "/v1/filters/regions", method = RequestMethod.GET) ResponseEntity<Object> getRegions(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/filters/accounts", method = RequestMethod.GET) ResponseEntity<Object> getAccounts(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/filters/rules", method = RequestMethod.GET) ResponseEntity<Object> getRules(@RequestParam("ag") String assetGroup, @RequestParam("domain") String domain); @RequestMapping(path = "/v1/filters/application", method = RequestMethod.GET) ResponseEntity<Object> getListOfApplications(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "domain", required = false) String domain); @RequestMapping(path = "/v1/filters/environment", method = RequestMethod.GET) ResponseEntity<Object> getListOfEnvironments(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "application", required = false) String application,
            @RequestParam(name = "domain", required = false) String domain); @GetMapping(value = "/v1/filters/targettype") ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "domain", required = false) String domain);  }