@Test public void testgetAdGroupsDetail() throws Exception { List<Map<String, String>> adList = new ArrayList<>(); Map<String, String> adMap = new HashMap<>(); adMap.put("group", "x"); adMap.put("admin", "y"); adList.add(adMap); when(service.getAdGroupsDetail(anyString(), anyString())).thenReturn(adList); ReflectionTestUtils.setField(controller, "assetService", service); ResponseEntity<Object> responseObj1 = controller.getAdGroupsDetail("ag", "a1"); assertTrue(responseObj1.getStatusCode() == HttpStatus.OK); doThrow(new NullPointerException()).when(service).getAdGroupsDetail(anyString(), anyString()); ResponseEntity<Object> responseObj2 = controller.getAdGroupsDetail("ag", "a1"); assertTrue(responseObj2.getStatusCode() == HttpStatus.OK); }
@ApiOperation(httpMethod = "GET", value = "Get the ad group details for a ec2 instance") @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/ad-groups") public ResponseEntity<Object> getAdGroupsDetail(@PathVariable(name = "assetGroup", required = true) String ag, @PathVariable(name = "resourceId", required = true) String resourceId) { List<Map<String, String>> adGroupsDetail; try { adGroupsDetail = assetService.getAdGroupsDetail(ag, resourceId); } catch (Exception e) { LOGGER.error("Error in getAdGroupsDetail ",e); adGroupsDetail = new ArrayList<>(); } return ResponseUtils.buildSucessResponse(adGroupsDetail); }
AssetDetailController { @ApiOperation(httpMethod = "GET", value = "Get the ad group details for a ec2 instance") @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/ad-groups") public ResponseEntity<Object> getAdGroupsDetail(@PathVariable(name = "assetGroup", required = true) String ag, @PathVariable(name = "resourceId", required = true) String resourceId) { List<Map<String, String>> adGroupsDetail; try { adGroupsDetail = assetService.getAdGroupsDetail(ag, resourceId); } catch (Exception e) { LOGGER.error("Error in getAdGroupsDetail ",e); adGroupsDetail = new ArrayList<>(); } return ResponseUtils.buildSucessResponse(adGroupsDetail); } }
AssetDetailController { @ApiOperation(httpMethod = "GET", value = "Get the ad group details for a ec2 instance") @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/ad-groups") public ResponseEntity<Object> getAdGroupsDetail(@PathVariable(name = "assetGroup", required = true) String ag, @PathVariable(name = "resourceId", required = true) String resourceId) { List<Map<String, String>> adGroupsDetail; try { adGroupsDetail = assetService.getAdGroupsDetail(ag, resourceId); } catch (Exception e) { LOGGER.error("Error in getAdGroupsDetail ",e); adGroupsDetail = new ArrayList<>(); } return ResponseUtils.buildSucessResponse(adGroupsDetail); }  }
AssetDetailController { @ApiOperation(httpMethod = "GET", value = "Get the ad group details for a ec2 instance") @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/ad-groups") public ResponseEntity<Object> getAdGroupsDetail(@PathVariable(name = "assetGroup", required = true) String ag, @PathVariable(name = "resourceId", required = true) String resourceId) { List<Map<String, String>> adGroupsDetail; try { adGroupsDetail = assetService.getAdGroupsDetail(ag, resourceId); } catch (Exception e) { LOGGER.error("Error in getAdGroupsDetail ",e); adGroupsDetail = new ArrayList<>(); } return ResponseUtils.buildSucessResponse(adGroupsDetail); }  @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/cpu-utilization") ResponseEntity<Object> getCPUUtilizationByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/disk-utilization", method = RequestMethod.GET) ResponseEntity<Object> getDiskUtilizationByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/installed-softwares", method = RequestMethod.GET) ResponseEntity<Object> getInstalledSoftwareDetailsByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId,
            @RequestParam(name = "from", required = false) Integer from,
            @RequestParam(name = "size", required = false) Integer size,
            @RequestParam(name = "searchtext", required = false) String searchText); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/open-ports", method = RequestMethod.GET) ResponseEntity<Object> getOpenPortsByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId,
            @RequestParam(name = "from", required = false) Integer from,
            @RequestParam(name = "size", required = false) Integer size,
            @RequestParam(name = "searchtext", required = false) String searchText); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/aws-notifications/summary", method = RequestMethod.GET) ResponseEntity<Object> getAwsNotificationSummary(
            @PathVariable(name = "resourceId", required = true) String instanceId); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/aws-notifications/details", method = RequestMethod.POST) ResponseEntity<Object> getAwsNotificationDetails(@RequestBody(required = true) PageFilterRequest request,
            @PathVariable(name = "resourceId", required = true) String instanceId); @ApiOperation(httpMethod = "GET", value = "Get the creator details for a particular resource") @GetMapping(value = "/v1/{assetGroup}/{resourceType}/{resourceId}/creatordetails") ResponseEntity<Object> getEc2CreatorDetail(
            @PathVariable(name = "assetGroup", required = true) String assetGroup,
            @PathVariable(name = "resourceType", required = true) String resourceType,
            @PathVariable(name = "resourceId", required = true) String resourceId); @ApiOperation(httpMethod = "GET", value = "Get the ad group details for a ec2 instance") @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/ad-groups") ResponseEntity<Object> getAdGroupsDetail(@PathVariable(name = "assetGroup", required = true) String ag,
            @PathVariable(name = "resourceId", required = true) String resourceId); @ApiOperation(httpMethod = "GET", value = "Get the details from a particular data source for a particular resource") @GetMapping(value = "v1/{assetGroup}/{resourceType}/{resourceId}/details") ResponseEntity<Object> getEc2ResourceDetail(@PathVariable(name = "assetGroup", required = true) String ag,
            @PathVariable(name = "resourceType", required = true) String resourceType,
            @PathVariable(name = "resourceId", required = true) String resourceId); @ApiOperation(httpMethod = "GET", value = "Get the average cost and total cost for an EC2 resource") @GetMapping(value = "v1/{assetGroup}/ec2/{resourceId}/cost") ResponseEntity<Object> getEc2ResourceSummary(
            @PathVariable(name = "resourceId", required = true) String resourceId); @ApiOperation(httpMethod = "GET", value = "Get the summary from AWS for a particular resource") @GetMapping(value = "v1/{assetGroup}/{resourceType}/{resourceId}/summary") ResponseEntity<Object> getEc2ResourceSummary(@PathVariable(name = "assetGroup", required = true) String ag,
            @PathVariable(name = "resourceType", required = true) String resourceType,
            @PathVariable(name = "resourceId", required = true) String resourceId); }
AssetDetailController { @ApiOperation(httpMethod = "GET", value = "Get the ad group details for a ec2 instance") @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/ad-groups") public ResponseEntity<Object> getAdGroupsDetail(@PathVariable(name = "assetGroup", required = true) String ag, @PathVariable(name = "resourceId", required = true) String resourceId) { List<Map<String, String>> adGroupsDetail; try { adGroupsDetail = assetService.getAdGroupsDetail(ag, resourceId); } catch (Exception e) { LOGGER.error("Error in getAdGroupsDetail ",e); adGroupsDetail = new ArrayList<>(); } return ResponseUtils.buildSucessResponse(adGroupsDetail); }  @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/cpu-utilization") ResponseEntity<Object> getCPUUtilizationByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/disk-utilization", method = RequestMethod.GET) ResponseEntity<Object> getDiskUtilizationByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/installed-softwares", method = RequestMethod.GET) ResponseEntity<Object> getInstalledSoftwareDetailsByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId,
            @RequestParam(name = "from", required = false) Integer from,
            @RequestParam(name = "size", required = false) Integer size,
            @RequestParam(name = "searchtext", required = false) String searchText); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/open-ports", method = RequestMethod.GET) ResponseEntity<Object> getOpenPortsByInstanceId(
            @PathVariable(name = "resourceId", required = true) String instanceId,
            @RequestParam(name = "from", required = false) Integer from,
            @RequestParam(name = "size", required = false) Integer size,
            @RequestParam(name = "searchtext", required = false) String searchText); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/aws-notifications/summary", method = RequestMethod.GET) ResponseEntity<Object> getAwsNotificationSummary(
            @PathVariable(name = "resourceId", required = true) String instanceId); @RequestMapping(path = "/v1/{assetGroup}/ec2/{resourceId}/aws-notifications/details", method = RequestMethod.POST) ResponseEntity<Object> getAwsNotificationDetails(@RequestBody(required = true) PageFilterRequest request,
            @PathVariable(name = "resourceId", required = true) String instanceId); @ApiOperation(httpMethod = "GET", value = "Get the creator details for a particular resource") @GetMapping(value = "/v1/{assetGroup}/{resourceType}/{resourceId}/creatordetails") ResponseEntity<Object> getEc2CreatorDetail(
            @PathVariable(name = "assetGroup", required = true) String assetGroup,
            @PathVariable(name = "resourceType", required = true) String resourceType,
            @PathVariable(name = "resourceId", required = true) String resourceId); @ApiOperation(httpMethod = "GET", value = "Get the ad group details for a ec2 instance") @GetMapping(value = "/v1/{assetGroup}/ec2/{resourceId}/ad-groups") ResponseEntity<Object> getAdGroupsDetail(@PathVariable(name = "assetGroup", required = true) String ag,
            @PathVariable(name = "resourceId", required = true) String resourceId); @ApiOperation(httpMethod = "GET", value = "Get the details from a particular data source for a particular resource") @GetMapping(value = "v1/{assetGroup}/{resourceType}/{resourceId}/details") ResponseEntity<Object> getEc2ResourceDetail(@PathVariable(name = "assetGroup", required = true) String ag,
            @PathVariable(name = "resourceType", required = true) String resourceType,
            @PathVariable(name = "resourceId", required = true) String resourceId); @ApiOperation(httpMethod = "GET", value = "Get the average cost and total cost for an EC2 resource") @GetMapping(value = "v1/{assetGroup}/ec2/{resourceId}/cost") ResponseEntity<Object> getEc2ResourceSummary(
            @PathVariable(name = "resourceId", required = true) String resourceId); @ApiOperation(httpMethod = "GET", value = "Get the summary from AWS for a particular resource") @GetMapping(value = "v1/{assetGroup}/{resourceType}/{resourceId}/summary") ResponseEntity<Object> getEc2ResourceSummary(@PathVariable(name = "assetGroup", required = true) String ag,
            @PathVariable(name = "resourceType", required = true) String resourceType,
            @PathVariable(name = "resourceId", required = true) String resourceId);  }