@Test public void testGetModelServiceVersionData() { logger.debug("testGetModelServiceVersionData: enter"); CreateDcaeMicroServiceController controller = new CreateDcaeMicroServiceController(); MockHttpServletResponse response = new MockHttpServletResponse(); String msModelJson = "{\"policyData\":\"DkatPolicyBody\"}"; try { CreateDcaeMicroServiceController.setCommonClassDao(commonClassDao); BufferedReader br = new BufferedReader(new StringReader(msModelJson)); when(request.getReader()).thenReturn(br); List<Object> microServiceModelsData = new ArrayList<Object>(); MicroServiceModels testData = new MicroServiceModels(); testData.setVersion("1707.4.1.2-Junit"); microServiceModelsData.add(testData); when(commonClassDao.getDataById(MicroServiceModels.class, "modelName", "DkatPolicyBody")) .thenReturn(microServiceModelsData); controller.getModelServiceVersionData(request, response); assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("1707.4.1.2-Junit")); logger.debug("response: " + response.getContentAsString()); } catch (Exception e) { logger.error("testGetModelServiceVersionData", e); fail("testGetModelServiceVersionData failed due to: " + e); } logger.debug("testGetModelServiceVersionData: exit"); }
@RequestMapping( value = {"/policyController/getModelServiceVersioneData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); String value = mapper.readTree(request.getReader()).get("policyData").toString().replaceAll("^\"|\"$", ""); String servicename = value.split("-v")[0]; Set<String> returnList = getVersionList(servicename); list.add(new JSONObject("{dcaeModelVersionData: " + mapper.writeValueAsString(returnList) + "}")); response.getWriter().write(list.toString()); return null; }
CreateDcaeMicroServiceController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/getModelServiceVersioneData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); String value = mapper.readTree(request.getReader()).get("policyData").toString().replaceAll("^\"|\"$", ""); String servicename = value.split("-v")[0]; Set<String> returnList = getVersionList(servicename); list.add(new JSONObject("{dcaeModelVersionData: " + mapper.writeValueAsString(returnList) + "}")); response.getWriter().write(list.toString()); return null; } }
CreateDcaeMicroServiceController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/getModelServiceVersioneData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); String value = mapper.readTree(request.getReader()).get("policyData").toString().replaceAll("^\"|\"$", ""); String servicename = value.split("-v")[0]; Set<String> returnList = getVersionList(servicename); list.add(new JSONObject("{dcaeModelVersionData: " + mapper.writeValueAsString(returnList) + "}")); response.getWriter().write(list.toString()); return null; } @Autowired private  CreateDcaeMicroServiceController(CommonClassDao commonClassDao);  CreateDcaeMicroServiceController(); }
CreateDcaeMicroServiceController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/getModelServiceVersioneData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); String value = mapper.readTree(request.getReader()).get("policyData").toString().replaceAll("^\"|\"$", ""); String servicename = value.split("-v")[0]; Set<String> returnList = getVersionList(servicename); list.add(new JSONObject("{dcaeModelVersionData: " + mapper.writeValueAsString(returnList) + "}")); response.getWriter().write(list.toString()); return null; } @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); }
CreateDcaeMicroServiceController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/getModelServiceVersioneData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); String value = mapper.readTree(request.getReader()).get("policyData").toString().replaceAll("^\"|\"$", ""); String servicename = value.split("-v")[0]; Set<String> returnList = getVersionList(servicename); list.add(new JSONObject("{dcaeModelVersionData: " + mapper.writeValueAsString(returnList) + "}")); response.getWriter().write(list.toString()); return null; } @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; }