### Question:
StatisticsController implements Constants { @RequestMapping(path = "/v1/disk-utilization", method = RequestMethod.GET) public ResponseEntity<Object> getDiskUtilization(@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.getDiskUtilization(assetGroup)); } catch (Exception e) { LOGGER.error("Error fetching Disk 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();  }### Answer:
@Test public void getDiskUtilizationTest() 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("diskReadinBytes",Math.random() * 1000 + 26); utilisation.put("diskWriteinBytes",Math.random() * 5000 + 12); utlisationList.add(utilisation); } when(statsService.getDiskUtilization(anyString())).thenReturn(utlisationList); ResponseEntity<Object> response = statisticsController.getDiskUtilization("aws-all"); assert(response.getStatusCodeValue()==200); }
@Test public void getDiskUtilizationExceptionTest() throws Exception { when(statsService.getDiskUtilization(anyString())).thenThrow( new ServiceException()); ResponseEntity<Object> response = statisticsController.getDiskUtilization("aws-all"); assert(response.getStatusCodeValue()!=200); }
@Test public void getDiskUtilizationNoAGTest() throws Exception { when(statsService.getDiskUtilization(anyString())).thenThrow( new ServiceException()); ResponseEntity<Object> response = statisticsController.getDiskUtilization(null); assert(response.getStatusCodeValue()!=200); }