AdminTabController extends RestrictedBaseController { @RequestMapping( value = {"/adminTabController/save_LockDownValue.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView saveAdminTabLockdownValue(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); try { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); String userId = UserUtils.getUserSession(request).getOrgUserId(); LOGGER.info( "********************Logging UserID for Application Lockdown Function**************************"); LOGGER.info("UserId: " + userId); LOGGER.info( "**********************************************************************************************"); JsonNode root = mapper.readTree(request.getReader()); GlobalRoleSettings globalRole = mapper.readValue(root.get("lockdowndata").toString(), GlobalRoleSettings.class); globalRole.setRole("super-admin"); commonClassDao.update(globalRole); response.setContentType(PolicyUtils.APPLICATION_JSON); String responseString = mapper.writeValueAsString(commonClassDao.getData(GlobalRoleSettings.class)); response.getWriter().write(new JSONObject("{descriptiveScopeDictionaryDatas: " + responseString + "}").toString()); } catch (Exception e) { LOGGER.error("Exception Occured" + e); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); } return null; } AdminTabController(); @Autowired private  AdminTabController(CommonClassDao commonClassDao); static CommonClassDao getCommonClassDao(); static void setCommonClassDao(CommonClassDao commonClassDao); @RequestMapping( value = {"/get_LockDownData"}, method = {org.springframework.web.bind.annotation.RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getAdminTabEntityData(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/adminTabController/save_LockDownValue.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView saveAdminTabLockdownValue(HttpServletRequest request, HttpServletResponse response);  }
@Test public void testSaveAdminRole() throws Exception { String data = "{\"lockdowndata\":{\"lockdown\":true}}"; BufferedReader reader = new BufferedReader(new StringReader(data)); try { when(request.getReader()).thenReturn(reader); admin.saveAdminTabLockdownValue(request, response); assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas")); } catch (UnsupportedEncodingException e) { logger.error("Exception Occured" + e); fail(); } }
@Test public void testSaveAdminTabLockdownValueException() throws IOException { assertNull(admin.saveAdminTabLockdownValue(request, response)); }