@Test(expected=Exception.class) public void testFetchComplianceInfoException() throws Exception { String complResponse = "{\"data1\":{\"distribution\":{\"tagging\":59,\"security\":89,\"costOptimization\":67,\"governance\":82,\"overall\":74}},\"message\":\"success\"}"; when(HttpUtil.get(anyString(),anyString())).thenReturn(complResponse); AssetGroupUtil.fetchComplianceInfo("", "", Arrays.asList("infra"),""); }
@SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchComplianceInfo(String apiUrl, String ag, List<String> domains ,String token) throws Exception { List<Map<String, Object>> compInfo = new ArrayList<>(); try { for (String domain : domains) { String typeCountJson = HttpUtil .get(apiUrl + "/overallcompliance?ag=" + ag + "&domain=" + Util.encodeUrl(domain),token); Map<String, Object> complianceMap = Util.parseJson(typeCountJson); Map<String, Map<String, Object>> data = (Map<String, Map<String, Object>>) complianceMap.get("data"); Map<String, Object> complianceStats = data.get(DISTRIBUTION); if (complianceStats != null) { complianceStats.put(DOMAIN, domain); compInfo.add(complianceStats); } } } catch (Exception e) { LOGGER.error("Error in fetchComplianceInfo" , e); throw e; } return compInfo; }
AssetGroupUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchComplianceInfo(String apiUrl, String ag, List<String> domains ,String token) throws Exception { List<Map<String, Object>> compInfo = new ArrayList<>(); try { for (String domain : domains) { String typeCountJson = HttpUtil .get(apiUrl + "/overallcompliance?ag=" + ag + "&domain=" + Util.encodeUrl(domain),token); Map<String, Object> complianceMap = Util.parseJson(typeCountJson); Map<String, Map<String, Object>> data = (Map<String, Map<String, Object>>) complianceMap.get("data"); Map<String, Object> complianceStats = data.get(DISTRIBUTION); if (complianceStats != null) { complianceStats.put(DOMAIN, domain); compInfo.add(complianceStats); } } } catch (Exception e) { LOGGER.error("Error in fetchComplianceInfo" , e); throw e; } return compInfo; } }
AssetGroupUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchComplianceInfo(String apiUrl, String ag, List<String> domains ,String token) throws Exception { List<Map<String, Object>> compInfo = new ArrayList<>(); try { for (String domain : domains) { String typeCountJson = HttpUtil .get(apiUrl + "/overallcompliance?ag=" + ag + "&domain=" + Util.encodeUrl(domain),token); Map<String, Object> complianceMap = Util.parseJson(typeCountJson); Map<String, Map<String, Object>> data = (Map<String, Map<String, Object>>) complianceMap.get("data"); Map<String, Object> complianceStats = data.get(DISTRIBUTION); if (complianceStats != null) { complianceStats.put(DOMAIN, domain); compInfo.add(complianceStats); } } } catch (Exception e) { LOGGER.error("Error in fetchComplianceInfo" , e); throw e; } return compInfo; } private  AssetGroupUtil(); }
AssetGroupUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchComplianceInfo(String apiUrl, String ag, List<String> domains ,String token) throws Exception { List<Map<String, Object>> compInfo = new ArrayList<>(); try { for (String domain : domains) { String typeCountJson = HttpUtil .get(apiUrl + "/overallcompliance?ag=" + ag + "&domain=" + Util.encodeUrl(domain),token); Map<String, Object> complianceMap = Util.parseJson(typeCountJson); Map<String, Map<String, Object>> data = (Map<String, Map<String, Object>>) complianceMap.get("data"); Map<String, Object> complianceStats = data.get(DISTRIBUTION); if (complianceStats != null) { complianceStats.put(DOMAIN, domain); compInfo.add(complianceStats); } } } catch (Exception e) { LOGGER.error("Error in fetchComplianceInfo" , e); throw e; } return compInfo; } 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); }
AssetGroupUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchComplianceInfo(String apiUrl, String ag, List<String> domains ,String token) throws Exception { List<Map<String, Object>> compInfo = new ArrayList<>(); try { for (String domain : domains) { String typeCountJson = HttpUtil .get(apiUrl + "/overallcompliance?ag=" + ag + "&domain=" + Util.encodeUrl(domain),token); Map<String, Object> complianceMap = Util.parseJson(typeCountJson); Map<String, Map<String, Object>> data = (Map<String, Map<String, Object>>) complianceMap.get("data"); Map<String, Object> complianceStats = data.get(DISTRIBUTION); if (complianceStats != null) { complianceStats.put(DOMAIN, domain); compInfo.add(complianceStats); } } } catch (Exception e) { LOGGER.error("Error in fetchComplianceInfo" , e); throw e; } return compInfo; } 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);  }