@Test public void testgetListOfTargetTypes() throws Exception { List<Map<String, Object>> tTypeList = new ArrayList<>(); when(service.getTargetTypesForAssetGroup(anyObject(), anyObject(), anyObject() )).thenReturn(tTypeList); ReflectionTestUtils.setField(controller, "assetService", service); ResponseEntity<Object> responseObj0 = controller.getListOfTargetTypes("ag", "domain", "provider"); assertTrue(responseObj0.getStatusCode() == HttpStatus.EXPECTATION_FAILED); Map<String, Object> tTypeMap = new HashMap<>(); tTypeMap.put("type", "ec2"); tTypeMap.put("category", "Compute"); tTypeMap.put("domain", "Infra & Platforms"); tTypeList.add(tTypeMap); ResponseEntity<Object> responseObj = controller.getListOfTargetTypes("ag", "domain", "provider"); assertTrue(responseObj.getStatusCode() == HttpStatus.OK); assertTrue(((Map<String, Object>) responseObj.getBody()).get("data") != null); }
@GetMapping(value = "/v1/list/targettype") public ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "domain", required = false) String domain, @RequestParam(name = "provider", required = false) String provider) { Map<String, Object> targetTypesResponse = new HashMap<>(); List<Map<String, Object>> targetTypes = assetService.getTargetTypesForAssetGroup(assetGroup, domain, provider); if (targetTypes.isEmpty()) { return ResponseUtils.buildFailureResponse(new Exception( "No target types found for the asset group . Please check the asset group configuration")); } else { targetTypesResponse.put("ag", assetGroup); targetTypesResponse.put("targettypes", targetTypes); return ResponseUtils.buildSucessResponse(targetTypesResponse); } }
AssetController { @GetMapping(value = "/v1/list/targettype") public ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "domain", required = false) String domain, @RequestParam(name = "provider", required = false) String provider) { Map<String, Object> targetTypesResponse = new HashMap<>(); List<Map<String, Object>> targetTypes = assetService.getTargetTypesForAssetGroup(assetGroup, domain, provider); if (targetTypes.isEmpty()) { return ResponseUtils.buildFailureResponse(new Exception( "No target types found for the asset group . Please check the asset group configuration")); } else { targetTypesResponse.put("ag", assetGroup); targetTypesResponse.put("targettypes", targetTypes); return ResponseUtils.buildSucessResponse(targetTypesResponse); } } }
AssetController { @GetMapping(value = "/v1/list/targettype") public ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "domain", required = false) String domain, @RequestParam(name = "provider", required = false) String provider) { Map<String, Object> targetTypesResponse = new HashMap<>(); List<Map<String, Object>> targetTypes = assetService.getTargetTypesForAssetGroup(assetGroup, domain, provider); if (targetTypes.isEmpty()) { return ResponseUtils.buildFailureResponse(new Exception( "No target types found for the asset group . Please check the asset group configuration")); } else { targetTypesResponse.put("ag", assetGroup); targetTypesResponse.put("targettypes", targetTypes); return ResponseUtils.buildSucessResponse(targetTypesResponse); } }  }
AssetController { @GetMapping(value = "/v1/list/targettype") public ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "domain", required = false) String domain, @RequestParam(name = "provider", required = false) String provider) { Map<String, Object> targetTypesResponse = new HashMap<>(); List<Map<String, Object>> targetTypes = assetService.getTargetTypesForAssetGroup(assetGroup, domain, provider); if (targetTypes.isEmpty()) { return ResponseUtils.buildFailureResponse(new Exception( "No target types found for the asset group . Please check the asset group configuration")); } else { targetTypesResponse.put("ag", assetGroup); targetTypesResponse.put("targettypes", targetTypes); return ResponseUtils.buildSucessResponse(targetTypesResponse); } }  @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 { @GetMapping(value = "/v1/list/targettype") public ResponseEntity<Object> getListOfTargetTypes(@RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "domain", required = false) String domain, @RequestParam(name = "provider", required = false) String provider) { Map<String, Object> targetTypesResponse = new HashMap<>(); List<Map<String, Object>> targetTypes = assetService.getTargetTypesForAssetGroup(assetGroup, domain, provider); if (targetTypes.isEmpty()) { return ResponseUtils.buildFailureResponse(new Exception( "No target types found for the asset group . Please check the asset group configuration")); } else { targetTypesResponse.put("ag", assetGroup); targetTypesResponse.put("targettypes", targetTypes); return ResponseUtils.buildSucessResponse(targetTypesResponse); } }  @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);  }