@Test public void testGetModelServiceVersionData() { logger.debug("testGetModelServiceVersionData: enter"); CreateOptimizationController controller = new CreateOptimizationController(); MockHttpServletResponse response = new MockHttpServletResponse(); String modelJson = "{\"policyData\":\"TestPolicyBody\"}"; try { CreateOptimizationController.setCommonClassDao(commonClassDao); BufferedReader br = new BufferedReader(new StringReader(modelJson)); when(request.getReader()).thenReturn(br); List<Object> optimizationModelsData = new ArrayList<Object>(); OptimizationModels testData = new OptimizationModels(); testData.setVersion("1707.4.1.2-Junit"); optimizationModelsData.add(testData); when(commonClassDao.getDataById(OptimizationModels.class, "modelName", "TestPolicyBody")) .thenReturn(optimizationModelsData); 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/getModelServiceVersionData.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); JsonNode root = mapper.readTree(request.getReader()); final String value = root.get("policyData").toString().replaceAll("^\"|\"$", ""); final String servicename = value.split("-v")[0]; response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); list.add(new JSONObject("{optimizationModelVersionData: " + mapper.writeValueAsString(getVersionList(servicename)) + "}")); response.getWriter().write(list.toString()); return null; }
CreateOptimizationController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/getModelServiceVersionData.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); JsonNode root = mapper.readTree(request.getReader()); final String value = root.get("policyData").toString().replaceAll("^\"|\"$", ""); final String servicename = value.split("-v")[0]; response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); list.add(new JSONObject("{optimizationModelVersionData: " + mapper.writeValueAsString(getVersionList(servicename)) + "}")); response.getWriter().write(list.toString()); return null; } }
CreateOptimizationController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/getModelServiceVersionData.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); JsonNode root = mapper.readTree(request.getReader()); final String value = root.get("policyData").toString().replaceAll("^\"|\"$", ""); final String servicename = value.split("-v")[0]; response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); list.add(new JSONObject("{optimizationModelVersionData: " + mapper.writeValueAsString(getVersionList(servicename)) + "}")); response.getWriter().write(list.toString()); return null; } @Autowired private  CreateOptimizationController(CommonClassDao commonClassDao);  CreateOptimizationController(); }
CreateOptimizationController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/getModelServiceVersionData.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); JsonNode root = mapper.readTree(request.getReader()); final String value = root.get("policyData").toString().replaceAll("^\"|\"$", ""); final String servicename = value.split("-v")[0]; response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); list.add(new JSONObject("{optimizationModelVersionData: " + mapper.writeValueAsString(getVersionList(servicename)) + "}")); response.getWriter().write(list.toString()); return null; } @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(); }
CreateOptimizationController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/getModelServiceVersionData.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); JsonNode root = mapper.readTree(request.getReader()); final String value = root.get("policyData").toString().replaceAll("^\"|\"$", ""); final String servicename = value.split("-v")[0]; response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.setContentType(PolicyUtils.APPLICATION_JSON); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); List<Object> list = new ArrayList<>(); list.add(new JSONObject("{optimizationModelVersionData: " + mapper.writeValueAsString(getVersionList(servicename)) + "}")); response.getWriter().write(list.toString()); return null; } @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; }