CreateDcaeMicroServiceController extends RestrictedBaseController { public Map<String, String> convertMap(Map<String, String> attributesMap, Map<String, String> attributesRefMap) { Map<String, String> attribute = new HashMap<>(); StringBuilder temp; String key; String value; for (Entry<String, String> entry : attributesMap.entrySet()) { key = entry.getKey(); value = entry.getValue(); attribute.put(key, value); } for (Entry<String, String> entryRef : attributesRefMap.entrySet()) { key = entryRef.getKey(); value = entryRef.getValue(); attribute.put(key, value); } for (Entry<String, String> entryList : attributesListRefMap.entrySet()) { key = entryList.getKey(); value = entryList.getValue(); attribute.put(key, value); } for (Entry<String, LinkedList<String>> arrayList : arrayTextList.entrySet()) { key = arrayList.getKey(); temp = null; for (Object textList : arrayList.getValue()) { if (temp == null) { temp = new StringBuilder(); temp.append("[" + textList); } else { temp.append("," + textList); } } attribute.put(key, temp + "]"); } return attribute; } @Autowired private  CreateDcaeMicroServiceController(CommonClassDao commonClassDao);  CreateDcaeMicroServiceController(); static CommonClassDao getCommonClassDao(); static void setCommonClassDao(CommonClassDao commonClassDao); PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root); boolean checkPattern(String patternString); void constructRule(StringBuilder sb, String jsonNode, Map<String, String> sigRules2); void parseData(JsonNode jsonNode, String string); String removeNullAttributes(String cleanJson); JsonArray removeNull(JsonArray array); JsonObject removeNull(JsonObject obj); String cleanUpJson(String json); JSONObject decodeContent(JsonNode jsonNode); @RequestMapping( value = {"/policyController/getDCAEMSTemplateData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView getDCAEMSTemplateData(HttpServletRequest request, HttpServletResponse response); JSONObject convertToArrayElement(JSONObject json, String keyValue); Set<String> getManyTrueProperties(String referAttributes); @RequestMapping( value = {"/policyController/getModelServiceVersioneData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_DCAEPriorityValues"}, method = {org.springframework.web.bind.annotation.RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getDCAEPriorityValuesData(HttpServletRequest request, HttpServletResponse response); void prePopulateDCAEMSPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity); Map<String, String> convert(String str, String split); @SuppressWarnings("unchecked") void readFile(PolicyRestAdapter policyAdapter, PolicyEntity entity); @SuppressWarnings({"rawtypes", "unchecked"}) void readRecursivlyJSONContent(Map<String, ?> map, Map<String, Object> data); String getPolicyScope(String value); Map<String, String> convertMap(Map<String, String> attributesMap, Map<String, String> attributesRefMap); @RequestMapping( value = {"/ms_dictionary/set_MSModelData"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) void SetMSModelData(HttpServletRequest request, HttpServletResponse response); void cleanUp(String path); void checkZipDirectory(String zipDirectory); Map<String, String> getAttributesListRefMap(); Map<String, LinkedList<String>> getArrayTextList(); Map<String, String> getSigRules(); void setSigRules(Map<String, String> sigRules); static final String DATATYPE; static final String PROPERTIES; static final String TYPE; static final String STRING; static final String INTEGER; static final String LIST; static final String DEFAULT; static final String REQUIRED; static final String MATCHABLE; static final String MANYFALSE; }
@Test public void testConvertMap() { logger.debug("testConvertMap: enter"); Map<String, String> attributesMap = new HashMap<String, String>(); attributesMap.put("keyOne", "valueOne"); attributesMap.put("keyTwo", "valueTwo"); attributesMap.put("keyThree", "valueThree"); Map<String, String> attributesRefMap = new HashMap<String, String>(); attributesRefMap.put("key4", "value4"); attributesRefMap.put("key5", "value5"); attributesRefMap.put("key6", "value6"); CreateDcaeMicroServiceController controller = new CreateDcaeMicroServiceController(); Map<String, String> attributesListRefMap = controller.getAttributesListRefMap(); LinkedList<String> list = new LinkedList<String>(); attributesListRefMap.put("key7", "value7"); list.add("l1"); list.add("l2"); Map<String, LinkedList<String>> arrayTextList = controller.getArrayTextList(); arrayTextList.put("key8", list); Map<String, String> result = controller.convertMap(attributesMap, attributesRefMap); assertTrue(result != null && result.size() == 8); assertTrue(arrayTextList.get("key8").toString().contains("[l1, l2]")); logger.debug("testConvertMap: exit"); }