@Test public void getPatchingDetailsTest() throws Exception { when(patchingService.getPatchingDetails(anyString(),anyObject())).thenReturn(CommonTestUtil.getListMapObject()); when(patchingService.filterMatchingCollectionElements(anyObject(),anyString(),anyBoolean())).thenReturn(CommonTestUtil.getListMapLong()); assertThat(patchingController.getPatchingDetails(CommonTestUtil.getRequest()), is(notNullValue())); assertThat(patchingController.getPatchingDetails(CommonTestUtil.getRequestFromLessThanZero()), is(notNullValue())); assertThat(patchingController.getPatchingDetails(CommonTestUtil.getRequestFromgreaterThanMasterList()), is(notNullValue())); assertThat(patchingController.getPatchingDetails(CommonTestUtil.getRequestEmpty()), is(notNullValue())); when(patchingService.getPatchingDetails(anyString(),anyObject())).thenThrow(new ServiceException()); when(complianceService.formatException(anyObject())).thenReturn(ResponseUtils.buildFailureResponse(new ServiceException())); ResponseEntity<Object> responseObj = patchingController.getPatchingDetails(CommonTestUtil.getRequest()); assertTrue(responseObj.getStatusCode() == HttpStatus.EXPECTATION_FAILED); }
@RequestMapping(path = "/v1/patching/detail", method = RequestMethod.POST) public ResponseEntity<Object> getPatchingDetails(@RequestBody(required = true) Request request) { ResponseWithCount response = null; String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); if (from < 0) { return ResponseUtils.buildFailureResponse(new Exception("From should not be a negative number")); } String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); try { List<Map<String, Object>> masterDetailList = patchingService.getPatchingDetails(assetGroup, filter); masterDetailList = (List<Map<String, Object>>) patchingService.filterMatchingCollectionElements( masterDetailList, searchText, true); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ArrayList<Map<String, Object>>()); } if (from >= masterDetailList.size()) { return ResponseUtils.buildFailureResponse(new ServiceException("From exceeds the size of list")); } int endIndex = 0; if ((from + size) > masterDetailList.size()) { endIndex = masterDetailList.size(); } else { endIndex = from + size; } if (endIndex == 0) { endIndex = masterDetailList.size(); } List<Map<String, Object>> subDetailList = masterDetailList.subList(from, endIndex); response = new ResponseWithCount(subDetailList, masterDetailList.size()); } catch (ServiceException e) { LOGGER.error(PATCHING_EXCEPTION, e.getMessage()); return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }
PatchingController implements Constants { @RequestMapping(path = "/v1/patching/detail", method = RequestMethod.POST) public ResponseEntity<Object> getPatchingDetails(@RequestBody(required = true) Request request) { ResponseWithCount response = null; String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); if (from < 0) { return ResponseUtils.buildFailureResponse(new Exception("From should not be a negative number")); } String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); try { List<Map<String, Object>> masterDetailList = patchingService.getPatchingDetails(assetGroup, filter); masterDetailList = (List<Map<String, Object>>) patchingService.filterMatchingCollectionElements( masterDetailList, searchText, true); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ArrayList<Map<String, Object>>()); } if (from >= masterDetailList.size()) { return ResponseUtils.buildFailureResponse(new ServiceException("From exceeds the size of list")); } int endIndex = 0; if ((from + size) > masterDetailList.size()) { endIndex = masterDetailList.size(); } else { endIndex = from + size; } if (endIndex == 0) { endIndex = masterDetailList.size(); } List<Map<String, Object>> subDetailList = masterDetailList.subList(from, endIndex); response = new ResponseWithCount(subDetailList, masterDetailList.size()); } catch (ServiceException e) { LOGGER.error(PATCHING_EXCEPTION, e.getMessage()); return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); } }
PatchingController implements Constants { @RequestMapping(path = "/v1/patching/detail", method = RequestMethod.POST) public ResponseEntity<Object> getPatchingDetails(@RequestBody(required = true) Request request) { ResponseWithCount response = null; String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); if (from < 0) { return ResponseUtils.buildFailureResponse(new Exception("From should not be a negative number")); } String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); try { List<Map<String, Object>> masterDetailList = patchingService.getPatchingDetails(assetGroup, filter); masterDetailList = (List<Map<String, Object>>) patchingService.filterMatchingCollectionElements( masterDetailList, searchText, true); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ArrayList<Map<String, Object>>()); } if (from >= masterDetailList.size()) { return ResponseUtils.buildFailureResponse(new ServiceException("From exceeds the size of list")); } int endIndex = 0; if ((from + size) > masterDetailList.size()) { endIndex = masterDetailList.size(); } else { endIndex = from + size; } if (endIndex == 0) { endIndex = masterDetailList.size(); } List<Map<String, Object>> subDetailList = masterDetailList.subList(from, endIndex); response = new ResponseWithCount(subDetailList, masterDetailList.size()); } catch (ServiceException e) { LOGGER.error(PATCHING_EXCEPTION, e.getMessage()); return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  }
PatchingController implements Constants { @RequestMapping(path = "/v1/patching/detail", method = RequestMethod.POST) public ResponseEntity<Object> getPatchingDetails(@RequestBody(required = true) Request request) { ResponseWithCount response = null; String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); if (from < 0) { return ResponseUtils.buildFailureResponse(new Exception("From should not be a negative number")); } String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); try { List<Map<String, Object>> masterDetailList = patchingService.getPatchingDetails(assetGroup, filter); masterDetailList = (List<Map<String, Object>>) patchingService.filterMatchingCollectionElements( masterDetailList, searchText, true); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ArrayList<Map<String, Object>>()); } if (from >= masterDetailList.size()) { return ResponseUtils.buildFailureResponse(new ServiceException("From exceeds the size of list")); } int endIndex = 0; if ((from + size) > masterDetailList.size()) { endIndex = masterDetailList.size(); } else { endIndex = from + size; } if (endIndex == 0) { endIndex = masterDetailList.size(); } List<Map<String, Object>> subDetailList = masterDetailList.subList(from, endIndex); response = new ResponseWithCount(subDetailList, masterDetailList.size()); } catch (ServiceException e) { LOGGER.error(PATCHING_EXCEPTION, e.getMessage()); return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/patching/topnoncompliantapps", method = RequestMethod.GET) ResponseEntity<Object> getTopNonCompliantApps(@RequestParam(name = "ag", required = true) String assetGroup); @RequestMapping(path = "/v1/patching/topnoncompliantexecs", method = RequestMethod.GET) ResponseEntity<Object> getTopNonCompliantExecs(@RequestParam(name = "ag", required = true) String assetGroup); @RequestMapping(path = "/v1/patching/detail", method = RequestMethod.POST) ResponseEntity<Object> getPatchingDetails(@RequestBody(required = true) Request request); @RequestMapping(path = "/v1/patching/progress", method = RequestMethod.POST) ResponseEntity<Object> getPatchingProgress(@RequestBody(required = true) PatchingRequest request); @RequestMapping(path = "/v1/patching/quarters", method = RequestMethod.POST) ResponseEntity<Object> getQuartersWithPatchingData(String assetGroup); @RequestMapping(path = "/v1/patching/rating", method = RequestMethod.GET) ResponseEntity<Object> getPatchingDataForAgForQuarter(String ag, int quarter, int year); }
PatchingController implements Constants { @RequestMapping(path = "/v1/patching/detail", method = RequestMethod.POST) public ResponseEntity<Object> getPatchingDetails(@RequestBody(required = true) Request request) { ResponseWithCount response = null; String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); if (from < 0) { return ResponseUtils.buildFailureResponse(new Exception("From should not be a negative number")); } String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); try { List<Map<String, Object>> masterDetailList = patchingService.getPatchingDetails(assetGroup, filter); masterDetailList = (List<Map<String, Object>>) patchingService.filterMatchingCollectionElements( masterDetailList, searchText, true); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ArrayList<Map<String, Object>>()); } if (from >= masterDetailList.size()) { return ResponseUtils.buildFailureResponse(new ServiceException("From exceeds the size of list")); } int endIndex = 0; if ((from + size) > masterDetailList.size()) { endIndex = masterDetailList.size(); } else { endIndex = from + size; } if (endIndex == 0) { endIndex = masterDetailList.size(); } List<Map<String, Object>> subDetailList = masterDetailList.subList(from, endIndex); response = new ResponseWithCount(subDetailList, masterDetailList.size()); } catch (ServiceException e) { LOGGER.error(PATCHING_EXCEPTION, e.getMessage()); return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/patching/topnoncompliantapps", method = RequestMethod.GET) ResponseEntity<Object> getTopNonCompliantApps(@RequestParam(name = "ag", required = true) String assetGroup); @RequestMapping(path = "/v1/patching/topnoncompliantexecs", method = RequestMethod.GET) ResponseEntity<Object> getTopNonCompliantExecs(@RequestParam(name = "ag", required = true) String assetGroup); @RequestMapping(path = "/v1/patching/detail", method = RequestMethod.POST) ResponseEntity<Object> getPatchingDetails(@RequestBody(required = true) Request request); @RequestMapping(path = "/v1/patching/progress", method = RequestMethod.POST) ResponseEntity<Object> getPatchingProgress(@RequestBody(required = true) PatchingRequest request); @RequestMapping(path = "/v1/patching/quarters", method = RequestMethod.POST) ResponseEntity<Object> getQuartersWithPatchingData(String assetGroup); @RequestMapping(path = "/v1/patching/rating", method = RequestMethod.GET) ResponseEntity<Object> getPatchingDataForAgForQuarter(String ag, int quarter, int year);  }