@Test public void testgetMinMaxAssetCount() throws Exception { List<Map<String, Object>> trendList = new ArrayList<>(); when(service.getAssetMinMax(anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(trendList); ReflectionTestUtils.setField(controller, "assetService", service); ResponseEntity<Object> responseObj0 = controller.getMinMaxAssetCount("ag","type",null,null, "domain"); assertTrue(responseObj0.getStatusCode() == HttpStatus.OK); doThrow(new NullPointerException()).when(service).getAssetMinMax(anyObject(), anyObject(), anyObject(), anyObject()); ResponseEntity<Object> responseObj1 = controller.getMinMaxAssetCount("ag","type",null,null, "domain"); assertTrue(responseObj1.getStatusCode() == HttpStatus.EXPECTATION_FAILED); }
@ApiOperation(value = "View the asset trends(daily min/max) over the period of last 1 month", response = Iterable.class) @GetMapping(path = "/v1/trend/minmax") public ResponseEntity<Object> getMinMaxAssetCount(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "type", required = true) String type, @RequestParam(name = "from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate, @RequestParam(name = "to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate, @RequestParam(name = "domain", required = false) String domain) { try { Date from = fromDate; Date to = toDate; if (from == null && to == null) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); to = cal.getTime(); cal.add(Calendar.DATE, Constants.NEG_THIRTY); from = cal.getTime(); } Map<String, Object> response = new LinkedHashMap<>(); response.put("ag", assetGroup); response.put("type", type); List<Map<String, Object>> trendList = assetService.getAssetMinMax(assetGroup, type, from, to); response.put("trend", trendList); return ResponseUtils.buildSucessResponse(response); } catch (Exception e) { return ResponseUtils.buildFailureResponse(e); } }
AssetTrendController { @ApiOperation(value = "View the asset trends(daily min/max) over the period of last 1 month", response = Iterable.class) @GetMapping(path = "/v1/trend/minmax") public ResponseEntity<Object> getMinMaxAssetCount(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "type", required = true) String type, @RequestParam(name = "from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate, @RequestParam(name = "to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate, @RequestParam(name = "domain", required = false) String domain) { try { Date from = fromDate; Date to = toDate; if (from == null && to == null) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); to = cal.getTime(); cal.add(Calendar.DATE, Constants.NEG_THIRTY); from = cal.getTime(); } Map<String, Object> response = new LinkedHashMap<>(); response.put("ag", assetGroup); response.put("type", type); List<Map<String, Object>> trendList = assetService.getAssetMinMax(assetGroup, type, from, to); response.put("trend", trendList); return ResponseUtils.buildSucessResponse(response); } catch (Exception e) { return ResponseUtils.buildFailureResponse(e); } } }
AssetTrendController { @ApiOperation(value = "View the asset trends(daily min/max) over the period of last 1 month", response = Iterable.class) @GetMapping(path = "/v1/trend/minmax") public ResponseEntity<Object> getMinMaxAssetCount(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "type", required = true) String type, @RequestParam(name = "from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate, @RequestParam(name = "to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate, @RequestParam(name = "domain", required = false) String domain) { try { Date from = fromDate; Date to = toDate; if (from == null && to == null) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); to = cal.getTime(); cal.add(Calendar.DATE, Constants.NEG_THIRTY); from = cal.getTime(); } Map<String, Object> response = new LinkedHashMap<>(); response.put("ag", assetGroup); response.put("type", type); List<Map<String, Object>> trendList = assetService.getAssetMinMax(assetGroup, type, from, to); response.put("trend", trendList); return ResponseUtils.buildSucessResponse(response); } catch (Exception e) { return ResponseUtils.buildFailureResponse(e); } }  }
AssetTrendController { @ApiOperation(value = "View the asset trends(daily min/max) over the period of last 1 month", response = Iterable.class) @GetMapping(path = "/v1/trend/minmax") public ResponseEntity<Object> getMinMaxAssetCount(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "type", required = true) String type, @RequestParam(name = "from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate, @RequestParam(name = "to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate, @RequestParam(name = "domain", required = false) String domain) { try { Date from = fromDate; Date to = toDate; if (from == null && to == null) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); to = cal.getTime(); cal.add(Calendar.DATE, Constants.NEG_THIRTY); from = cal.getTime(); } Map<String, Object> response = new LinkedHashMap<>(); response.put("ag", assetGroup); response.put("type", type); List<Map<String, Object>> trendList = assetService.getAssetMinMax(assetGroup, type, from, to); response.put("trend", trendList); return ResponseUtils.buildSucessResponse(response); } catch (Exception e) { return ResponseUtils.buildFailureResponse(e); } }  @ApiOperation(value = "View the asset trends(daily min/max) over the period of last 1 month", response = Iterable.class) @GetMapping(path = "/v1/trend/minmax") ResponseEntity<Object> getMinMaxAssetCount(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "type", required = true) String type,
            @RequestParam(name = "from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate,
            @RequestParam(name = "to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate,
            @RequestParam(name = "domain", required = false) String domain); }
AssetTrendController { @ApiOperation(value = "View the asset trends(daily min/max) over the period of last 1 month", response = Iterable.class) @GetMapping(path = "/v1/trend/minmax") public ResponseEntity<Object> getMinMaxAssetCount(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "type", required = true) String type, @RequestParam(name = "from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate, @RequestParam(name = "to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate, @RequestParam(name = "domain", required = false) String domain) { try { Date from = fromDate; Date to = toDate; if (from == null && to == null) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); to = cal.getTime(); cal.add(Calendar.DATE, Constants.NEG_THIRTY); from = cal.getTime(); } Map<String, Object> response = new LinkedHashMap<>(); response.put("ag", assetGroup); response.put("type", type); List<Map<String, Object>> trendList = assetService.getAssetMinMax(assetGroup, type, from, to); response.put("trend", trendList); return ResponseUtils.buildSucessResponse(response); } catch (Exception e) { return ResponseUtils.buildFailureResponse(e); } }  @ApiOperation(value = "View the asset trends(daily min/max) over the period of last 1 month", response = Iterable.class) @GetMapping(path = "/v1/trend/minmax") ResponseEntity<Object> getMinMaxAssetCount(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "type", required = true) String type,
            @RequestParam(name = "from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate,
            @RequestParam(name = "to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate,
            @RequestParam(name = "domain", required = false) String domain);  }