@Test public void testupdateAsset() throws Exception { AssetUpdateRequest assetUpdateRequest = new AssetUpdateRequest(); assetUpdateRequest.setAg("ag"); assetUpdateRequest.setTargettype("targetType"); assetUpdateRequest.setUpdateBy("update_by"); assetUpdateRequest.setUpdates(new ArrayList<>()); assetUpdateRequest.setResources(new HashMap<>()); when(service.updateAsset(anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(0); ReflectionTestUtils.setField(controller, "assetService", service); ResponseEntity<Object> responseObj4 = controller.updateAsset(assetUpdateRequest); assertTrue(responseObj4.getStatusCode() == HttpStatus.EXPECTATION_FAILED); when(service.updateAsset(anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(1); ReflectionTestUtils.setField(controller, "assetService", service); ResponseEntity<Object> responseObj = controller.updateAsset(assetUpdateRequest); assertTrue(responseObj.getStatusCode() == HttpStatus.OK); assertTrue(((Map<String, Object>) responseObj.getBody()).get("data") != null); assetUpdateRequest.setUpdateBy(null); ResponseEntity<Object> responseObj0 = controller.updateAsset(assetUpdateRequest); assertTrue(responseObj0.getStatusCode() == HttpStatus.OK); assetUpdateRequest.setAg(""); ResponseEntity<Object> responseObj2 = controller.updateAsset(assetUpdateRequest); assertTrue(responseObj2.getStatusCode() == HttpStatus.EXPECTATION_FAILED); assetUpdateRequest.setAg("aws-all"); assetUpdateRequest.setTargettype(""); ResponseEntity<Object> responseObj3 = controller.updateAsset(assetUpdateRequest); assertTrue(responseObj3.getStatusCode() == HttpStatus.EXPECTATION_FAILED); }
@ApiOperation(httpMethod = "POST", value = "Update Asset values") @PostMapping(value = "/v1/update-asset") public ResponseEntity<Object> updateAsset(@RequestBody(required = true) AssetUpdateRequest request) throws DataException { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception("Asset group is Mandatory")); } String targettype = request.getTargettype(); if (Strings.isNullOrEmpty(targettype)) { return ResponseUtils.buildFailureResponse(new Exception("Target type is Mandatory")); } String updatedBy = request.getUpdateBy(); if (Strings.isNullOrEmpty(updatedBy)) { updatedBy = ""; } Map<String, Object> resources = request.getResources(); int totalRows = assetService .updateAsset(assetGroup, targettype, resources, updatedBy, request.getUpdates()); if (totalRows > 0) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new Exception("Update failed")); } }
AssetController { @ApiOperation(httpMethod = "POST", value = "Update Asset values") @PostMapping(value = "/v1/update-asset") public ResponseEntity<Object> updateAsset(@RequestBody(required = true) AssetUpdateRequest request) throws DataException { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception("Asset group is Mandatory")); } String targettype = request.getTargettype(); if (Strings.isNullOrEmpty(targettype)) { return ResponseUtils.buildFailureResponse(new Exception("Target type is Mandatory")); } String updatedBy = request.getUpdateBy(); if (Strings.isNullOrEmpty(updatedBy)) { updatedBy = ""; } Map<String, Object> resources = request.getResources(); int totalRows = assetService .updateAsset(assetGroup, targettype, resources, updatedBy, request.getUpdates()); if (totalRows > 0) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new Exception("Update failed")); } } }
AssetController { @ApiOperation(httpMethod = "POST", value = "Update Asset values") @PostMapping(value = "/v1/update-asset") public ResponseEntity<Object> updateAsset(@RequestBody(required = true) AssetUpdateRequest request) throws DataException { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception("Asset group is Mandatory")); } String targettype = request.getTargettype(); if (Strings.isNullOrEmpty(targettype)) { return ResponseUtils.buildFailureResponse(new Exception("Target type is Mandatory")); } String updatedBy = request.getUpdateBy(); if (Strings.isNullOrEmpty(updatedBy)) { updatedBy = ""; } Map<String, Object> resources = request.getResources(); int totalRows = assetService .updateAsset(assetGroup, targettype, resources, updatedBy, request.getUpdates()); if (totalRows > 0) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new Exception("Update failed")); } }  }
AssetController { @ApiOperation(httpMethod = "POST", value = "Update Asset values") @PostMapping(value = "/v1/update-asset") public ResponseEntity<Object> updateAsset(@RequestBody(required = true) AssetUpdateRequest request) throws DataException { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception("Asset group is Mandatory")); } String targettype = request.getTargettype(); if (Strings.isNullOrEmpty(targettype)) { return ResponseUtils.buildFailureResponse(new Exception("Target type is Mandatory")); } String updatedBy = request.getUpdateBy(); if (Strings.isNullOrEmpty(updatedBy)) { updatedBy = ""; } Map<String, Object> resources = request.getResources(); int totalRows = assetService .updateAsset(assetGroup, targettype, resources, updatedBy, request.getUpdates()); if (totalRows > 0) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new Exception("Update failed")); } }  @GetMapping(value = "/v1/list/targettype") ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "domain", required = false) String domain,
    	@RequestParam(name = "provider", required = false) String provider); @GetMapping(value = "/v1/list/application") ResponseEntity<Object> getListOfApplications(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "domain", required = false) String domain); @GetMapping(value = "/v1/list/environment") ResponseEntity<Object> getListOfEnvironments(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "application", required = false) String application,
            @RequestParam(name = "domain", required = false) String domain); @GetMapping(value = "/v1/list/assetgroup") ResponseEntity<Object> getAllAssetGroups(); @GetMapping(value = "/v1/assetgroup") ResponseEntity<Object> getAssetGroupInfo(@RequestParam(name = "ag", required = true) String assetGroup); @ApiOperation(httpMethod = "GET", value = "Get User Default Asset Group") @GetMapping(value = "/v1/list/user-default-assetgroup") ResponseEntity<Object> getUserDefaultAssetGroup(
            @ApiParam(value = "Provide the User Id for getting the Default Asset Group", required = true) @RequestParam(name = "userId", required = true) String userId); @ApiOperation(httpMethod = "POST", value = "Save or Update User Asset Groups") @PostMapping(value = "/v1/save-or-update/assetgroup") ResponseEntity<Object> saveOrUpdateAssetGroup(
            @ApiParam(value = "Provide Default Asset Group and the User Id", required = true) @RequestBody(required = true) DefaultUserAssetGroup defaultUserAssetGroup); @ApiOperation(httpMethod = "POST", value = "Save or Append User Recently Viewed Asset Groups") @PostMapping(value = "/v1/appendToRecentlyViewedAG") ResponseEntity<Object> appendToRecentlyViewedAG(
            @RequestParam(name = "userId", required = true) String userId,
            @RequestParam(name = "ag", required = true) String assetGroup); @ApiOperation(httpMethod = "GET", value = "Retrieve Asset Config for the given resourceId and configType") @GetMapping(value = "/v1/retrieve-asset-config") ResponseEntity<Object> retrieveAssetConfig(
            @RequestParam(name = "resourceId", required = true) String resourceId,
            @RequestParam(name = "configType", required = true) String configType); @ApiOperation(httpMethod = "POST", value = "Save Asset Configuration") @PostMapping(value = "/v1/save-asset-config") ResponseEntity<Object> saveAssetConfig(
            @RequestParam(name = "resourceId", required = true) String resourceId,
            @RequestParam(name = "configType", required = true) String configType,
            @RequestBody(required = true) String config); @ApiOperation(httpMethod = "POST", value = "Update Asset values") @PostMapping(value = "/v1/update-asset") ResponseEntity<Object> updateAsset(@RequestBody(required = true) AssetUpdateRequest request); @ApiOperation(httpMethod = "GET", value = "Get Resource Created Date") @RequestMapping(path = "/v1/get-resource-created-date", method = RequestMethod.GET) @ResponseBody ResponseEntity<Object> getResourceCreatedDate(
            @ApiParam(value = "Provide Valid Resource Id", required = true) @RequestParam(name = "resourceId", required = true) String resourceId,
            @ApiParam(value = "Provide Valid Resource Type", required = true) @RequestParam(name = "resourceType", required = false) String resourceType); }
AssetController { @ApiOperation(httpMethod = "POST", value = "Update Asset values") @PostMapping(value = "/v1/update-asset") public ResponseEntity<Object> updateAsset(@RequestBody(required = true) AssetUpdateRequest request) throws DataException { String assetGroup = request.getAg(); if (Strings.isNullOrEmpty(assetGroup)) { return ResponseUtils.buildFailureResponse(new Exception("Asset group is Mandatory")); } String targettype = request.getTargettype(); if (Strings.isNullOrEmpty(targettype)) { return ResponseUtils.buildFailureResponse(new Exception("Target type is Mandatory")); } String updatedBy = request.getUpdateBy(); if (Strings.isNullOrEmpty(updatedBy)) { updatedBy = ""; } Map<String, Object> resources = request.getResources(); int totalRows = assetService .updateAsset(assetGroup, targettype, resources, updatedBy, request.getUpdates()); if (totalRows > 0) { return ResponseUtils.buildSucessResponse(HttpStatus.OK); } else { return ResponseUtils.buildFailureResponse(new Exception("Update failed")); } }  @GetMapping(value = "/v1/list/targettype") ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "domain", required = false) String domain,
    	@RequestParam(name = "provider", required = false) String provider); @GetMapping(value = "/v1/list/application") ResponseEntity<Object> getListOfApplications(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "domain", required = false) String domain); @GetMapping(value = "/v1/list/environment") ResponseEntity<Object> getListOfEnvironments(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "application", required = false) String application,
            @RequestParam(name = "domain", required = false) String domain); @GetMapping(value = "/v1/list/assetgroup") ResponseEntity<Object> getAllAssetGroups(); @GetMapping(value = "/v1/assetgroup") ResponseEntity<Object> getAssetGroupInfo(@RequestParam(name = "ag", required = true) String assetGroup); @ApiOperation(httpMethod = "GET", value = "Get User Default Asset Group") @GetMapping(value = "/v1/list/user-default-assetgroup") ResponseEntity<Object> getUserDefaultAssetGroup(
            @ApiParam(value = "Provide the User Id for getting the Default Asset Group", required = true) @RequestParam(name = "userId", required = true) String userId); @ApiOperation(httpMethod = "POST", value = "Save or Update User Asset Groups") @PostMapping(value = "/v1/save-or-update/assetgroup") ResponseEntity<Object> saveOrUpdateAssetGroup(
            @ApiParam(value = "Provide Default Asset Group and the User Id", required = true) @RequestBody(required = true) DefaultUserAssetGroup defaultUserAssetGroup); @ApiOperation(httpMethod = "POST", value = "Save or Append User Recently Viewed Asset Groups") @PostMapping(value = "/v1/appendToRecentlyViewedAG") ResponseEntity<Object> appendToRecentlyViewedAG(
            @RequestParam(name = "userId", required = true) String userId,
            @RequestParam(name = "ag", required = true) String assetGroup); @ApiOperation(httpMethod = "GET", value = "Retrieve Asset Config for the given resourceId and configType") @GetMapping(value = "/v1/retrieve-asset-config") ResponseEntity<Object> retrieveAssetConfig(
            @RequestParam(name = "resourceId", required = true) String resourceId,
            @RequestParam(name = "configType", required = true) String configType); @ApiOperation(httpMethod = "POST", value = "Save Asset Configuration") @PostMapping(value = "/v1/save-asset-config") ResponseEntity<Object> saveAssetConfig(
            @RequestParam(name = "resourceId", required = true) String resourceId,
            @RequestParam(name = "configType", required = true) String configType,
            @RequestBody(required = true) String config); @ApiOperation(httpMethod = "POST", value = "Update Asset values") @PostMapping(value = "/v1/update-asset") ResponseEntity<Object> updateAsset(@RequestBody(required = true) AssetUpdateRequest request); @ApiOperation(httpMethod = "GET", value = "Get Resource Created Date") @RequestMapping(path = "/v1/get-resource-created-date", method = RequestMethod.GET) @ResponseBody ResponseEntity<Object> getResourceCreatedDate(
            @ApiParam(value = "Provide Valid Resource Id", required = true) @RequestParam(name = "resourceId", required = true) String resourceId,
            @ApiParam(value = "Provide Valid Resource Type", required = true) @RequestParam(name = "resourceType", required = false) String resourceType);  }