@Test public void testFetchAssetGroups() throws Exception { String listAgJson = "{\"data\":[{\"name\":\"abcservices\",\"domains\":[\"Infra & Platforms\"]},{\"name\":\"adapt\",\"domains\":[\"Infra & Platforms\"]},{\"name\":\"adapt-workload\",\"domains\":[\"Infra & Platforms\"]}]}"; when(HttpUtil.get(anyString(),anyString())).thenReturn(listAgJson); Map<String, List<String>> agInfo = AssetGroupUtil.fetchAssetGroups("",""); assertThat(agInfo.size(), is(3)); }
@SuppressWarnings("unchecked") public static Map<String, List<String>> fetchAssetGroups(String asstApiUri,String token) throws Exception { String assetGroupJson = HttpUtil.get(asstApiUri + "/list/assetgroup",token); Map<String, Object> assetInfoMap = Util.parseJson(assetGroupJson); Map<String, List<String>> assetGroups = new HashMap<>(); if (!assetInfoMap.isEmpty()) { assetGroups = ((List<Map<String, Object>>) assetInfoMap.get("data")).stream().collect( Collectors.toMap(obj -> obj.get("name").toString(), obj -> (List<String>) obj.get("domains"))); } return assetGroups; }
AssetGroupUtil { @SuppressWarnings("unchecked") public static Map<String, List<String>> fetchAssetGroups(String asstApiUri,String token) throws Exception { String assetGroupJson = HttpUtil.get(asstApiUri + "/list/assetgroup",token); Map<String, Object> assetInfoMap = Util.parseJson(assetGroupJson); Map<String, List<String>> assetGroups = new HashMap<>(); if (!assetInfoMap.isEmpty()) { assetGroups = ((List<Map<String, Object>>) assetInfoMap.get("data")).stream().collect( Collectors.toMap(obj -> obj.get("name").toString(), obj -> (List<String>) obj.get("domains"))); } return assetGroups; } }
AssetGroupUtil { @SuppressWarnings("unchecked") public static Map<String, List<String>> fetchAssetGroups(String asstApiUri,String token) throws Exception { String assetGroupJson = HttpUtil.get(asstApiUri + "/list/assetgroup",token); Map<String, Object> assetInfoMap = Util.parseJson(assetGroupJson); Map<String, List<String>> assetGroups = new HashMap<>(); if (!assetInfoMap.isEmpty()) { assetGroups = ((List<Map<String, Object>>) assetInfoMap.get("data")).stream().collect( Collectors.toMap(obj -> obj.get("name").toString(), obj -> (List<String>) obj.get("domains"))); } return assetGroups; } private  AssetGroupUtil(); }
AssetGroupUtil { @SuppressWarnings("unchecked") public static Map<String, List<String>> fetchAssetGroups(String asstApiUri,String token) throws Exception { String assetGroupJson = HttpUtil.get(asstApiUri + "/list/assetgroup",token); Map<String, Object> assetInfoMap = Util.parseJson(assetGroupJson); Map<String, List<String>> assetGroups = new HashMap<>(); if (!assetInfoMap.isEmpty()) { assetGroups = ((List<Map<String, Object>>) assetInfoMap.get("data")).stream().collect( Collectors.toMap(obj -> obj.get("name").toString(), obj -> (List<String>) obj.get("domains"))); } return assetGroups; } 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 Map<String, List<String>> fetchAssetGroups(String asstApiUri,String token) throws Exception { String assetGroupJson = HttpUtil.get(asstApiUri + "/list/assetgroup",token); Map<String, Object> assetInfoMap = Util.parseJson(assetGroupJson); Map<String, List<String>> assetGroups = new HashMap<>(); if (!assetInfoMap.isEmpty()) { assetGroups = ((List<Map<String, Object>>) assetInfoMap.get("data")).stream().collect( Collectors.toMap(obj -> obj.get("name").toString(), obj -> (List<String>) obj.get("domains"))); } return assetGroups; } 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);  }