### Question:
AssetGroupUtil { public static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token) throws Exception { Map<String, Object> vulnSummary = new HashMap<>(); try { String vulnSummaryResponse = HttpUtil.get(compapiuri + "/vulnerabilites?ag=" + ag,token); JsonObject vulnSummaryJson = new JsonParser().parse(vulnSummaryResponse).getAsJsonObject(); JsonObject vulnJsonObj = vulnSummaryJson.get("data").getAsJsonObject().get(OUTPUT).getAsJsonObject(); long total = vulnJsonObj.get("hosts").getAsLong(); long noncompliant = vulnJsonObj.get("totalVulnerableAssets").getAsLong(); vulnSummary.put(TOTAL, total); vulnSummary.put(NON_COMPLIANT, noncompliant); vulnSummary.put(COMPLIANT, total - noncompliant); } catch (Exception e) { LOGGER.error("Error retrieving vuln sumamary " , e); throw e; } return vulnSummary; } private  AssetGroupUtil(); @SuppressWarnings("unchecked") static Map<String, List<String>> fetchAssetGroups(String asstApiUri,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchTypeCounts(String asstApiUri, String ag,String token); static Map<String, Object> fetchPatchingCompliance(String api, String ag ,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchVulnDistribution(String api, String ag ,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchComplianceInfo(String apiUrl, String ag, List<String> domains ,String token); static List<Map<String, Object>> fetchRuleComplianceInfo(String compapiuri, String ag,
            List<String> domains ,String token); static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token); static Map<String, Object> fetchTaggingSummary(String compapiuri, String ag ,String token); static Map<String, Object> fetchCertSummary(String compapiuri, String ag ,String token); static List<Map<String, Object>> fetchIssuesInfo(String compapiuri, String ag, List<String> domains ,String token);  }### Answer:
@Test public void testFetchVulnSummary() throws Exception { String vulnSummaryJson = "{\"data\":{\"output\":{\"hosts\":7192,\"vulnerabilities\":132285,\"totalVulnerableAssets\":5815}},\"message\":\"success\"}"; when(HttpUtil.get(anyString(),anyString())).thenReturn(vulnSummaryJson); Map<String, Object> vulnSummary = AssetGroupUtil.fetchVulnSummary("", "",""); assertThat(vulnSummary.get("total"), is(7192l)); }
@Test(expected=Exception.class) public void testFetchVulnSummaryException() throws Exception { String vulnSummaryJson = "{\"data1\":{\"output\":{\"hosts\":7192,\"vulnerabilities\":132285,\"totalVulnerableAssets\":5815}},\"message\":\"success\"}"; when(HttpUtil.get(anyString(),anyString())).thenReturn(vulnSummaryJson); AssetGroupUtil.fetchVulnSummary("", "",""); }