@Test public void getTaggingSummaryTest() throws Exception { Map<String, Long> tagMap = new HashMap<>(); tagMap.put("ec2", 100l); tagMap.put("s3", 200l); tagMap.put("assets", 200l); Gson gson = new Gson(); List<JsonObject> paramsList = new ArrayList<>(); JsonObject paramsKeyValue = new JsonObject(); paramsKeyValue.add("key", gson.fromJson("mandatoryTags", JsonElement.class)); paramsKeyValue.add("value", gson.fromJson("Application", JsonElement.class)); paramsList.add(paramsKeyValue); JsonObject ruleParam = new JsonObject(); ruleParam.add("params", gson.fromJson(paramsList.toString(), JsonElement.class)); Map<String, Object> mainRuleParams = new HashMap<>(); mainRuleParams.put("ruleParams", ruleParam); List<Map<String, Object>> mainRuleParamsList = new ArrayList<>(); mainRuleParamsList.add(mainRuleParams); when(complainceRepository.getTagging(anyString(), anyString())) .thenReturn(tagMap); when(repository.getRuleParamsFromDbByPolicyId(anyString())).thenReturn( mainRuleParamsList); assertThat(taggingServiceImpl.getTaggingSummary("test"), is(notNullValue())); when(complainceRepository.getTagging(anyString(), anyString())) .thenThrow(new DataException()); assertThatThrownBy(() -> taggingServiceImpl.getTaggingSummary("test")) .isInstanceOf(ServiceException.class); }
public Map<String, Object> getTaggingSummary(String assetGroup) throws ServiceException { List<String> mandatoryTagsList = new ArrayList<>(); String ruleMandatoryTags = mandatoryTags; if (!StringUtils.isEmpty(ruleMandatoryTags)) { mandatoryTagsList = Arrays.asList(ruleMandatoryTags.split(",")); } Map<String, Object> totalMap = new HashMap<>(); List<Map<String, Object>> unTagsList = new ArrayList<>(); Map<String, Long> tagMap; try { tagMap = complainceRepository.getTagging(assetGroup, null); } catch (DataException e) { throw new ServiceException(e); } unTagsList = getUnTaggedListData(unTagsList, assetGroup, mandatoryTagsList, tagMap); totalMap.put("untaggedList", unTagsList); totalMap.put("overallCompliance", tagMap.get("compliance")); return totalMap; }
TaggingServiceImpl implements TaggingService, Constants { public Map<String, Object> getTaggingSummary(String assetGroup) throws ServiceException { List<String> mandatoryTagsList = new ArrayList<>(); String ruleMandatoryTags = mandatoryTags; if (!StringUtils.isEmpty(ruleMandatoryTags)) { mandatoryTagsList = Arrays.asList(ruleMandatoryTags.split(",")); } Map<String, Object> totalMap = new HashMap<>(); List<Map<String, Object>> unTagsList = new ArrayList<>(); Map<String, Long> tagMap; try { tagMap = complainceRepository.getTagging(assetGroup, null); } catch (DataException e) { throw new ServiceException(e); } unTagsList = getUnTaggedListData(unTagsList, assetGroup, mandatoryTagsList, tagMap); totalMap.put("untaggedList", unTagsList); totalMap.put("overallCompliance", tagMap.get("compliance")); return totalMap; } }
TaggingServiceImpl implements TaggingService, Constants { public Map<String, Object> getTaggingSummary(String assetGroup) throws ServiceException { List<String> mandatoryTagsList = new ArrayList<>(); String ruleMandatoryTags = mandatoryTags; if (!StringUtils.isEmpty(ruleMandatoryTags)) { mandatoryTagsList = Arrays.asList(ruleMandatoryTags.split(",")); } Map<String, Object> totalMap = new HashMap<>(); List<Map<String, Object>> unTagsList = new ArrayList<>(); Map<String, Long> tagMap; try { tagMap = complainceRepository.getTagging(assetGroup, null); } catch (DataException e) { throw new ServiceException(e); } unTagsList = getUnTaggedListData(unTagsList, assetGroup, mandatoryTagsList, tagMap); totalMap.put("untaggedList", unTagsList); totalMap.put("overallCompliance", tagMap.get("compliance")); return totalMap; }  }
TaggingServiceImpl implements TaggingService, Constants { public Map<String, Object> getTaggingSummary(String assetGroup) throws ServiceException { List<String> mandatoryTagsList = new ArrayList<>(); String ruleMandatoryTags = mandatoryTags; if (!StringUtils.isEmpty(ruleMandatoryTags)) { mandatoryTagsList = Arrays.asList(ruleMandatoryTags.split(",")); } Map<String, Object> totalMap = new HashMap<>(); List<Map<String, Object>> unTagsList = new ArrayList<>(); Map<String, Long> tagMap; try { tagMap = complainceRepository.getTagging(assetGroup, null); } catch (DataException e) { throw new ServiceException(e); } unTagsList = getUnTaggedListData(unTagsList, assetGroup, mandatoryTagsList, tagMap); totalMap.put("untaggedList", unTagsList); totalMap.put("overallCompliance", tagMap.get("compliance")); return totalMap; }  @Override ResponseWithCount getUnTaggedAssetsByApplication(Request request); Map<String, Object> getTaggingSummary(String assetGroup); List<Map<String, Object>> getUntaggingByTargetTypes(UntaggedTargetTypeRequest request); @Override List<Map<String, Long>> taggingByApplication(String assetGroup, String targetType); }
TaggingServiceImpl implements TaggingService, Constants { public Map<String, Object> getTaggingSummary(String assetGroup) throws ServiceException { List<String> mandatoryTagsList = new ArrayList<>(); String ruleMandatoryTags = mandatoryTags; if (!StringUtils.isEmpty(ruleMandatoryTags)) { mandatoryTagsList = Arrays.asList(ruleMandatoryTags.split(",")); } Map<String, Object> totalMap = new HashMap<>(); List<Map<String, Object>> unTagsList = new ArrayList<>(); Map<String, Long> tagMap; try { tagMap = complainceRepository.getTagging(assetGroup, null); } catch (DataException e) { throw new ServiceException(e); } unTagsList = getUnTaggedListData(unTagsList, assetGroup, mandatoryTagsList, tagMap); totalMap.put("untaggedList", unTagsList); totalMap.put("overallCompliance", tagMap.get("compliance")); return totalMap; }  @Override ResponseWithCount getUnTaggedAssetsByApplication(Request request); Map<String, Object> getTaggingSummary(String assetGroup); List<Map<String, Object>> getUntaggingByTargetTypes(UntaggedTargetTypeRequest request); @Override List<Map<String, Long>> taggingByApplication(String assetGroup, String targetType);  }