@Test public void updateProjectionDataFalseTest() throws Exception { ProjectionRequest projectionRequest = new ProjectionRequest(); projectionRequest.setYear(2018); projectionRequest.setResourceType("onpremserver"); when(projectionService.updateProjection(anyObject())).thenReturn(false); assertThat(projectionController.updateProjectionData(projectionRequest), is(notNullValue())); }
@ApiOperation(httpMethod = "POST", value = "Save or Update Projection Details") @PostMapping(value = "/v1/updateprojection") public ResponseEntity<Object> updateProjectionData(@RequestBody ProjectionRequest projectionRequest) throws ServiceException { if (Strings.isNullOrEmpty(projectionRequest.getResourceType()) || projectionRequest.getYear() <= 0 || projectionRequest.getQuarter() <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("targetType/year/quarter is mandatory")); } if (projectionRequest.getQuarter() > FOUR) { return ResponseUtils.buildFailureResponse(new ServiceException("Invalid quarter")); } boolean isDataupdatedtoDB = false; try { isDataupdatedtoDB = projectionService.updateProjection(projectionRequest); } catch (ServiceException e) { LOGGER.error(e.toString()); return ResponseUtils.buildFailureResponse(e); } if (isDataupdatedtoDB) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new ServiceException("Projection Details Saving Failed")); } }
ProjectionController implements Constants { @ApiOperation(httpMethod = "POST", value = "Save or Update Projection Details") @PostMapping(value = "/v1/updateprojection") public ResponseEntity<Object> updateProjectionData(@RequestBody ProjectionRequest projectionRequest) throws ServiceException { if (Strings.isNullOrEmpty(projectionRequest.getResourceType()) || projectionRequest.getYear() <= 0 || projectionRequest.getQuarter() <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("targetType/year/quarter is mandatory")); } if (projectionRequest.getQuarter() > FOUR) { return ResponseUtils.buildFailureResponse(new ServiceException("Invalid quarter")); } boolean isDataupdatedtoDB = false; try { isDataupdatedtoDB = projectionService.updateProjection(projectionRequest); } catch (ServiceException e) { LOGGER.error(e.toString()); return ResponseUtils.buildFailureResponse(e); } if (isDataupdatedtoDB) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new ServiceException("Projection Details Saving Failed")); } } }
ProjectionController implements Constants { @ApiOperation(httpMethod = "POST", value = "Save or Update Projection Details") @PostMapping(value = "/v1/updateprojection") public ResponseEntity<Object> updateProjectionData(@RequestBody ProjectionRequest projectionRequest) throws ServiceException { if (Strings.isNullOrEmpty(projectionRequest.getResourceType()) || projectionRequest.getYear() <= 0 || projectionRequest.getQuarter() <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("targetType/year/quarter is mandatory")); } if (projectionRequest.getQuarter() > FOUR) { return ResponseUtils.buildFailureResponse(new ServiceException("Invalid quarter")); } boolean isDataupdatedtoDB = false; try { isDataupdatedtoDB = projectionService.updateProjection(projectionRequest); } catch (ServiceException e) { LOGGER.error(e.toString()); return ResponseUtils.buildFailureResponse(e); } if (isDataupdatedtoDB) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new ServiceException("Projection Details Saving Failed")); } }  }
ProjectionController implements Constants { @ApiOperation(httpMethod = "POST", value = "Save or Update Projection Details") @PostMapping(value = "/v1/updateprojection") public ResponseEntity<Object> updateProjectionData(@RequestBody ProjectionRequest projectionRequest) throws ServiceException { if (Strings.isNullOrEmpty(projectionRequest.getResourceType()) || projectionRequest.getYear() <= 0 || projectionRequest.getQuarter() <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("targetType/year/quarter is mandatory")); } if (projectionRequest.getQuarter() > FOUR) { return ResponseUtils.buildFailureResponse(new ServiceException("Invalid quarter")); } boolean isDataupdatedtoDB = false; try { isDataupdatedtoDB = projectionService.updateProjection(projectionRequest); } catch (ServiceException e) { LOGGER.error(e.toString()); return ResponseUtils.buildFailureResponse(e); } if (isDataupdatedtoDB) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new ServiceException("Projection Details Saving Failed")); } }  @RequestMapping(path = "/v1/getprojection", method = RequestMethod.GET) ResponseEntity<Object> getProjectionData(
            @RequestParam(name = "targettype", required = true) String targetType,
            @RequestParam(name = "year", required = true) int year,
            @RequestParam(name = "quarter", required = true) int quarter); @ApiOperation(httpMethod = "POST", value = "Save or Update Projection Details") @PostMapping(value = "/v1/updateprojection") ResponseEntity<Object> updateProjectionData(@RequestBody ProjectionRequest projectionRequest); @RequestMapping(path = "/v1/getPatchingAndProjectionProgress", method = RequestMethod.GET) ResponseEntity<Object> getPatchingAndProjectionProgress(
            @RequestParam(name = "ag", required = true) String assetGroup); @RequestMapping(path = "/v1/getPatchingProgressByDirector", method = RequestMethod.POST) ResponseEntity<Object> patchingProgressByDirector(@RequestBody(required = false) Request request); @RequestMapping(path = "/v1/getPatchingProgressByExecutiveSponsor", method = RequestMethod.POST) ResponseEntity<Object> patchingProgressByExecutiveSponser(@RequestBody(required = false) Request request); }
ProjectionController implements Constants { @ApiOperation(httpMethod = "POST", value = "Save or Update Projection Details") @PostMapping(value = "/v1/updateprojection") public ResponseEntity<Object> updateProjectionData(@RequestBody ProjectionRequest projectionRequest) throws ServiceException { if (Strings.isNullOrEmpty(projectionRequest.getResourceType()) || projectionRequest.getYear() <= 0 || projectionRequest.getQuarter() <= 0) { return ResponseUtils.buildFailureResponse(new ServiceException("targetType/year/quarter is mandatory")); } if (projectionRequest.getQuarter() > FOUR) { return ResponseUtils.buildFailureResponse(new ServiceException("Invalid quarter")); } boolean isDataupdatedtoDB = false; try { isDataupdatedtoDB = projectionService.updateProjection(projectionRequest); } catch (ServiceException e) { LOGGER.error(e.toString()); return ResponseUtils.buildFailureResponse(e); } if (isDataupdatedtoDB) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new ServiceException("Projection Details Saving Failed")); } }  @RequestMapping(path = "/v1/getprojection", method = RequestMethod.GET) ResponseEntity<Object> getProjectionData(
            @RequestParam(name = "targettype", required = true) String targetType,
            @RequestParam(name = "year", required = true) int year,
            @RequestParam(name = "quarter", required = true) int quarter); @ApiOperation(httpMethod = "POST", value = "Save or Update Projection Details") @PostMapping(value = "/v1/updateprojection") ResponseEntity<Object> updateProjectionData(@RequestBody ProjectionRequest projectionRequest); @RequestMapping(path = "/v1/getPatchingAndProjectionProgress", method = RequestMethod.GET) ResponseEntity<Object> getPatchingAndProjectionProgress(
            @RequestParam(name = "ag", required = true) String assetGroup); @RequestMapping(path = "/v1/getPatchingProgressByDirector", method = RequestMethod.POST) ResponseEntity<Object> patchingProgressByDirector(@RequestBody(required = false) Request request); @RequestMapping(path = "/v1/getPatchingProgressByExecutiveSponsor", method = RequestMethod.POST) ResponseEntity<Object> patchingProgressByExecutiveSponser(@RequestBody(required = false) Request request);  }