### Question:
AssetGroupUtil { public static Map<String, Object> fetchTaggingSummary(String compapiuri, String ag ,String token) throws Exception { Map<String, Object> taggingSummary = new HashMap<>(); try { String taggingSummaryResponse = HttpUtil.get(compapiuri + "/tagging?ag=" + ag,token); JsonObject taggingSummaryJson = new JsonParser().parse(taggingSummaryResponse).getAsJsonObject(); JsonObject taggingJsonObj = taggingSummaryJson.get("data").getAsJsonObject().get(OUTPUT) .getAsJsonObject(); long total = taggingJsonObj.get("assets").getAsLong(); long noncompliant = taggingJsonObj.get("untagged").getAsLong(); long compliant = taggingJsonObj.get("tagged").getAsLong(); taggingSummary.put(TOTAL, total); taggingSummary.put(NON_COMPLIANT, noncompliant); taggingSummary.put(COMPLIANT, compliant); } catch (Exception e) { LOGGER.error("Error retrieving tagging sumamary " , e); throw e; } return taggingSummary; } 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 testFetchTaggingSummary() throws Exception { String tagSummaryJson = "{\"data\":{\"output\":{\"assets\":124704,\"untagged\":49384,\"tagged\":75320,\"compliance\":60}},\"message\":\"success\"}"; when(HttpUtil.get(anyString(),anyString())).thenReturn(tagSummaryJson); Map<String, Object> tagSummary = AssetGroupUtil.fetchTaggingSummary("", "",""); assertThat(tagSummary.get("total"), is(124704l)); }
@Test(expected=Exception.class) public void testFetchTaggingSummaryException() throws Exception { String tagSummaryJson = "{\"data1\":{\"output\":{\"assets\":124704,\"untagged\":49384,\"tagged\":75320,\"compliance\":60}},\"message\":\"success\"}"; when(HttpUtil.get(anyString(),anyString())).thenReturn(tagSummaryJson); AssetGroupUtil.fetchTaggingSummary("", "",""); }