@Test public void getNetworkUtilizationTest() throws Exception { LocalDate currDate = LocalDate.now(); Map<String,Object> utilisation; List< Map<String,Object>> utlisationList = new ArrayList<>(); for(int i=0;i<7;i++){ LocalDate temp = currDate.minusDays(i); String date = temp.format(DateTimeFormatter.ISO_DATE); utilisation = new HashMap<>(); utilisation.put("date",date); utilisation.put("networkIn",Math.random() * 1000 + 26); utilisation.put("networkOut",Math.random() * 5000 + 12); utlisationList.add(utilisation); } when(statsService.getNetworkUtilization(anyString())).thenReturn(utlisationList); ResponseEntity<Object> response = statisticsController.getNetworkUtilization("aws-all"); assert(response.getStatusCodeValue()==200); }
@RequestMapping(path = "/v1/network-utilization", method = RequestMethod.GET) public ResponseEntity<Object> getNetworkUtilization(@RequestParam("ag") String assetGroup) { if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(StatsConstants.ERR_MSG_AG_MANDATORY)); } ResponseVO response; try { response = new ResponseVO(statsService.getNetworkUtilization(assetGroup)); } catch (Exception e) { LOGGER.error("Error fetching Nework Utilisation", e); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); }
StatisticsController implements Constants { @RequestMapping(path = "/v1/network-utilization", method = RequestMethod.GET) public ResponseEntity<Object> getNetworkUtilization(@RequestParam("ag") String assetGroup) { if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(StatsConstants.ERR_MSG_AG_MANDATORY)); } ResponseVO response; try { response = new ResponseVO(statsService.getNetworkUtilization(assetGroup)); } catch (Exception e) { LOGGER.error("Error fetching Nework Utilisation", e); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); } }
StatisticsController implements Constants { @RequestMapping(path = "/v1/network-utilization", method = RequestMethod.GET) public ResponseEntity<Object> getNetworkUtilization(@RequestParam("ag") String assetGroup) { if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(StatsConstants.ERR_MSG_AG_MANDATORY)); } ResponseVO response; try { response = new ResponseVO(statsService.getNetworkUtilization(assetGroup)); } catch (Exception e) { LOGGER.error("Error fetching Nework Utilisation", e); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); }  }
StatisticsController implements Constants { @RequestMapping(path = "/v1/network-utilization", method = RequestMethod.GET) public ResponseEntity<Object> getNetworkUtilization(@RequestParam("ag") String assetGroup) { if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(StatsConstants.ERR_MSG_AG_MANDATORY)); } ResponseVO response; try { response = new ResponseVO(statsService.getNetworkUtilization(assetGroup)); } catch (Exception e) { LOGGER.error("Error fetching Nework Utilisation", e); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/cpu-utilization", method = RequestMethod.GET) ResponseEntity<Object> getCPUUtilization(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/network-utilization", method = RequestMethod.GET) ResponseEntity<Object> getNetworkUtilization(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/disk-utilization", method = RequestMethod.GET) ResponseEntity<Object> getDiskUtilization(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/statsdetails", method = RequestMethod.GET) @ResponseBody ResponseEntity<Object> getStatsDetails(); @RequestMapping(path = "/v1/autofixstats", method = RequestMethod.GET) @ResponseBody ResponseEntity<Object> getAutofixStats(); }
StatisticsController implements Constants { @RequestMapping(path = "/v1/network-utilization", method = RequestMethod.GET) public ResponseEntity<Object> getNetworkUtilization(@RequestParam("ag") String assetGroup) { if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception(StatsConstants.ERR_MSG_AG_MANDATORY)); } ResponseVO response; try { response = new ResponseVO(statsService.getNetworkUtilization(assetGroup)); } catch (Exception e) { LOGGER.error("Error fetching Nework Utilisation", e); return ResponseUtils.buildFailureResponse(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/cpu-utilization", method = RequestMethod.GET) ResponseEntity<Object> getCPUUtilization(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/network-utilization", method = RequestMethod.GET) ResponseEntity<Object> getNetworkUtilization(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/disk-utilization", method = RequestMethod.GET) ResponseEntity<Object> getDiskUtilization(@RequestParam("ag") String assetGroup); @RequestMapping(path = "/v1/statsdetails", method = RequestMethod.GET) @ResponseBody ResponseEntity<Object> getStatsDetails(); @RequestMapping(path = "/v1/autofixstats", method = RequestMethod.GET) @ResponseBody ResponseEntity<Object> getAutofixStats();  }