@Test public void getCertificatesDetailsTest_Exception() throws Exception { Request request = new Request(); when(certificateService.getCerticatesDetails(anyString(), anyString(), anyObject())).thenThrow(new ServiceException()); assertTrue(certificateController.getCertificatesDetails(request).getStatusCode() == HttpStatus.EXPECTATION_FAILED); }
@RequestMapping(path = "/v1/certificates/detail", method = RequestMethod.POST) public ResponseEntity<Object> getCertificatesDetails( @RequestBody(required = true) Request request) { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new ServiceException( ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); if (filter == null) { filter = new HashMap<>(); } if (from < 0) { return ResponseUtils.buildFailureResponse(new ServiceException( "From should not be a negative number")); } ResponseWithCount response; try { List<Map<String, Object>> masterDetailList = certificateService .getCerticatesDetails(assetGroup, searchText, filter); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ResponseWithCount( new ArrayList<Map<String, Object>>(), 0)); } 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 (Exception e) { LOGGER.error(EXE_CERT_EXPIRY , e.getMessage()); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); }
CertificateController implements Constants { @RequestMapping(path = "/v1/certificates/detail", method = RequestMethod.POST) public ResponseEntity<Object> getCertificatesDetails( @RequestBody(required = true) Request request) { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new ServiceException( ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); if (filter == null) { filter = new HashMap<>(); } if (from < 0) { return ResponseUtils.buildFailureResponse(new ServiceException( "From should not be a negative number")); } ResponseWithCount response; try { List<Map<String, Object>> masterDetailList = certificateService .getCerticatesDetails(assetGroup, searchText, filter); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ResponseWithCount( new ArrayList<Map<String, Object>>(), 0)); } 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 (Exception e) { LOGGER.error(EXE_CERT_EXPIRY , e.getMessage()); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); } }
CertificateController implements Constants { @RequestMapping(path = "/v1/certificates/detail", method = RequestMethod.POST) public ResponseEntity<Object> getCertificatesDetails( @RequestBody(required = true) Request request) { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new ServiceException( ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); if (filter == null) { filter = new HashMap<>(); } if (from < 0) { return ResponseUtils.buildFailureResponse(new ServiceException( "From should not be a negative number")); } ResponseWithCount response; try { List<Map<String, Object>> masterDetailList = certificateService .getCerticatesDetails(assetGroup, searchText, filter); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ResponseWithCount( new ArrayList<Map<String, Object>>(), 0)); } 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 (Exception e) { LOGGER.error(EXE_CERT_EXPIRY , e.getMessage()); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); }  }
CertificateController implements Constants { @RequestMapping(path = "/v1/certificates/detail", method = RequestMethod.POST) public ResponseEntity<Object> getCertificatesDetails( @RequestBody(required = true) Request request) { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new ServiceException( ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); if (filter == null) { filter = new HashMap<>(); } if (from < 0) { return ResponseUtils.buildFailureResponse(new ServiceException( "From should not be a negative number")); } ResponseWithCount response; try { List<Map<String, Object>> masterDetailList = certificateService .getCerticatesDetails(assetGroup, searchText, filter); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ResponseWithCount( new ArrayList<Map<String, Object>>(), 0)); } 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 (Exception e) { LOGGER.error(EXE_CERT_EXPIRY , e.getMessage()); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/certificates/expirybyapplication", method = RequestMethod.GET) ResponseEntity<Object> getCerticatesExpiryByApplication(
            @RequestParam(name = "ag", required = true) String assetGroup); @RequestMapping(path = "/v1/certificates/detail", method = RequestMethod.POST) ResponseEntity<Object> getCertificatesDetails(
            @RequestBody(required = true) Request request); @RequestMapping(path = "/v1/certificates/summary", method = RequestMethod.GET) ResponseEntity<Object> getCertificatesSummary(
            @RequestParam(name = "ag", required = true) String assetGroup); }
CertificateController implements Constants { @RequestMapping(path = "/v1/certificates/detail", method = RequestMethod.POST) public ResponseEntity<Object> getCertificatesDetails( @RequestBody(required = true) Request request) { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new ServiceException( ASSET_MANDATORY)); } int from = request.getFrom(); int size = request.getSize(); String searchText = request.getSearchtext(); Map<String, String> filter = request.getFilter(); if (filter == null) { filter = new HashMap<>(); } if (from < 0) { return ResponseUtils.buildFailureResponse(new ServiceException( "From should not be a negative number")); } ResponseWithCount response; try { List<Map<String, Object>> masterDetailList = certificateService .getCerticatesDetails(assetGroup, searchText, filter); if (masterDetailList.isEmpty()) { return ResponseUtils.buildSucessResponse(new ResponseWithCount( new ArrayList<Map<String, Object>>(), 0)); } 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 (Exception e) { LOGGER.error(EXE_CERT_EXPIRY , e.getMessage()); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/certificates/expirybyapplication", method = RequestMethod.GET) ResponseEntity<Object> getCerticatesExpiryByApplication(
            @RequestParam(name = "ag", required = true) String assetGroup); @RequestMapping(path = "/v1/certificates/detail", method = RequestMethod.POST) ResponseEntity<Object> getCertificatesDetails(
            @RequestBody(required = true) Request request); @RequestMapping(path = "/v1/certificates/summary", method = RequestMethod.GET) ResponseEntity<Object> getCertificatesSummary(
            @RequestParam(name = "ag", required = true) String assetGroup);  }