CreateOptimizationController extends RestrictedBaseController { public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) { String jsonContent = null; try { LOGGER.info("policyJSON :" + (root.get("policyJSON")).toString()); String tempJson = root.get("policyJSON").toString(); String dummyValue = "*empty-value*" + UUID.randomUUID().toString(); LOGGER.info("dummyValue:" + dummyValue); tempJson = StringUtils.replaceEach(tempJson, new String[] {"\"\""}, new String[] {"\"" + dummyValue + "\""}); ObjectMapper mapper = new ObjectMapper(); JsonNode tempJsonNode = mapper.readTree(tempJson); jsonContent = msController.decodeContent(tempJsonNode).toString(); constructJson(policyData, jsonContent, dummyValue); } catch (Exception e) { LOGGER.error("Error while decoding microservice content", e); } return policyData; } @Autowired private  CreateOptimizationController(CommonClassDao commonClassDao);  CreateOptimizationController(); static CommonClassDao getCommonClassDao(); static void setCommonClassDao(CommonClassDao commonClassDao); PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root); @RequestMapping( value = {"/policyController/getOptimizationTemplateData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView getOptimizationTemplateData(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/policyController/getModelServiceVersionData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response); void prePopulatePolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity); @RequestMapping( value = {"/oof_dictionary/set_ModelData"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) void setModelData(HttpServletRequest request, HttpServletResponse response); Map<String, String> getAttributesListRefMap(); Map<String, LinkedList<String>> getArrayTextList(); 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; static final String MODEL; static final String MANY; static final String MODELNAME; }
@Test public void testSetDataToPolicyRestAdapter() { logger.debug("testSetDataToPolicyRestAdapter: enter"); CreateOptimizationController controller = new CreateOptimizationController(); CreateOptimizationController.setCommonClassDao(commonClassDao); JsonNode root = null; ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); PolicyRestAdapter policyData = null; try { root = JsonLoader.fromString(jsonString); policyData = mapper.readValue(root.get("policyData").get("policy").toString(), PolicyRestAdapter.class); } catch (Exception e) { logger.error("testSetDataToPolicyRestAdapter", e); } PolicyRestAdapter result = controller.setDataToPolicyRestAdapter(policyData, root); assertTrue(result != null && result.getJsonBody() != null && !result.getJsonBody().isEmpty()); logger.debug("result.getJsonBody() : " + result.getJsonBody()); logger.debug("testSetDataToPolicyRestAdapter: exit"); }