### Question:
AssetCountController { @GetMapping(value = "/v1/count/byenvironment") public ResponseEntity<Object> geAssetCountByTypeEnvironment( @RequestParam(name = "ag", required = true) String assetGroup, @RequestParam(name = "application", required = false) String application, @RequestParam(name = "type", required = true) String type) { if (Util.isValidTargetType(assetGroup, type)) { List<Map<String, Object>> countMap = null; try { countMap = assetService.getAssetCountByEnvironment(assetGroup, application, type); } catch (Exception e) { return ResponseUtils.buildFailureResponse(e); } Map<String, Object> response = new LinkedHashMap<>(); response.put("ag", assetGroup); response.put("type", type); response.put(AssetConstants.ASSET_COUNT, countMap); return ResponseUtils.buildSucessResponse(response); } else { return ResponseUtils.buildFailureResponse(new Exception("Invalid Target type for the assetgroup ")); } }  @GetMapping(value = "/v1/count") ResponseEntity<Object> geAssetCount(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "type", required = false) String type,
            @RequestParam(name = "domain", required = false) String domain,
            @RequestParam(name = "application", required = false) String application,
            @RequestParam(name = "provider", required = false) String provider); @GetMapping(value = "/v1/count/byapplication") ResponseEntity<Object> geAssetCountByTypeAndApplication(
            @RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "type", required = true) String type); @GetMapping(value = "/v1/count/byenvironment") ResponseEntity<Object> geAssetCountByTypeEnvironment(
            @RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "application", required = false) String application,
            @RequestParam(name = "type", required = true) String type);  }### Answer:
@Test public void testgeAssetCountByTypeEnvironment() throws Exception { List<Map<String, Object>> tTypeList = new ArrayList<>(); Map<String, Object> tTypeMap = new HashMap<>(); tTypeMap.put("count", "100"); tTypeMap.put("type", "ec2"); tTypeList.add(tTypeMap); mockStatic(Util.class); when(Util.isValidTargetType(anyString(), anyString())).thenReturn(true, true, false); when(service.getAssetCountByEnvironment(anyObject(), anyObject(), anyObject())).thenReturn(tTypeList); ReflectionTestUtils.setField(controller, "assetService", service); ResponseEntity<Object> responseObj = controller.geAssetCountByTypeEnvironment("ag", "app", "type"); assertTrue(responseObj.getStatusCode() == HttpStatus.OK); assertTrue(((Map<String, Object>) responseObj.getBody()).get("data") != null); doThrow(new NullPointerException()).when(service).getAssetCountByEnvironment(anyObject(), anyObject(), anyObject()); responseObj = controller.geAssetCountByTypeEnvironment("ag", "app", "type"); assertTrue(responseObj.getStatusCode() == HttpStatus.EXPECTATION_FAILED); responseObj = controller.geAssetCountByTypeEnvironment("ag", "app", "type"); assertTrue(responseObj.getStatusCode() == HttpStatus.EXPECTATION_FAILED); }