@Test(expected=Exception.class) public void testFetcTypeCountsException() throws Exception { String typeCountJson = "{\"data1\":{\"ag\":\"aws-all\",\"assetcount\":[{\"count\":1949,\"type\":\"subnet\"},{\"count\":5885,\"type\":\"stack\"},{\"count\":714,\"type\":\"asgpolicy\"},{\"count\":3926,\"type\":\"rdssnapshot\"},{\"count\":84,\"type\":\"rdscluster\"},{\"count\":1320,\"type\":\"cert\"},{\"count\":481,\"type\":\"internetgateway\"},{\"count\":419,\"type\":\"rdsdb\"}]}}"; when(HttpUtil.get(anyString(),anyString())).thenReturn(typeCountJson); List<Map<String, Object>> typeCounts = AssetGroupUtil.fetchTypeCounts("", "",""); assertThat(typeCounts.isEmpty(),is(true)); }
@SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchTypeCounts(String asstApiUri, String ag,String token) throws Exception { String typeCountJson = HttpUtil.get(asstApiUri + "/count?ag=" + ag,token); Map<String, Object> typeCountMap = Util.parseJson(typeCountJson); List<Map<String, Object>> typeCounts = new ArrayList<>(); try { typeCounts = (List<Map<String, Object>>) ((Map<String, Object>) typeCountMap.get("data")).get("assetcount"); } catch (Exception e) { LOGGER.error("Error in fetchTypeCounts",e); throw e; } return typeCounts; }
AssetGroupUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchTypeCounts(String asstApiUri, String ag,String token) throws Exception { String typeCountJson = HttpUtil.get(asstApiUri + "/count?ag=" + ag,token); Map<String, Object> typeCountMap = Util.parseJson(typeCountJson); List<Map<String, Object>> typeCounts = new ArrayList<>(); try { typeCounts = (List<Map<String, Object>>) ((Map<String, Object>) typeCountMap.get("data")).get("assetcount"); } catch (Exception e) { LOGGER.error("Error in fetchTypeCounts",e); throw e; } return typeCounts; } }
AssetGroupUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchTypeCounts(String asstApiUri, String ag,String token) throws Exception { String typeCountJson = HttpUtil.get(asstApiUri + "/count?ag=" + ag,token); Map<String, Object> typeCountMap = Util.parseJson(typeCountJson); List<Map<String, Object>> typeCounts = new ArrayList<>(); try { typeCounts = (List<Map<String, Object>>) ((Map<String, Object>) typeCountMap.get("data")).get("assetcount"); } catch (Exception e) { LOGGER.error("Error in fetchTypeCounts",e); throw e; } return typeCounts; } private  AssetGroupUtil(); }
AssetGroupUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> fetchTypeCounts(String asstApiUri, String ag,String token) throws Exception { String typeCountJson = HttpUtil.get(asstApiUri + "/count?ag=" + ag,token); Map<String, Object> typeCountMap = Util.parseJson(typeCountJson); List<Map<String, Object>> typeCounts = new ArrayList<>(); try { typeCounts = (List<Map<String, Object>>) ((Map<String, Object>) typeCountMap.get("data")).get("assetcount"); } catch (Exception e) { LOGGER.error("Error in fetchTypeCounts",e); throw e; } return typeCounts; } 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>> fetchTypeCounts(String asstApiUri, String ag,String token) throws Exception { String typeCountJson = HttpUtil.get(asstApiUri + "/count?ag=" + ag,token); Map<String, Object> typeCountMap = Util.parseJson(typeCountJson); List<Map<String, Object>> typeCounts = new ArrayList<>(); try { typeCounts = (List<Map<String, Object>>) ((Map<String, Object>) typeCountMap.get("data")).get("assetcount"); } catch (Exception e) { LOGGER.error("Error in fetchTypeCounts",e); throw e; } return typeCounts; } 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);  }