@Test(expected = NullPointerException.class) public void testMoveElement() throws IOException { req.setLocalName("en-US"); Mockito.when(userInstanceManager.getUserInstance(req)).thenReturn(null); ModelAndView modelAndView = updatePreferencesServlet.moveElement(req, res, "sourceId", "get", "elementId"); }
@RequestMapping(method = RequestMethod.POST, params = "action=moveElement") public ModelAndView moveElement( HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "sourceID") String sourceId, @RequestParam String method, @RequestParam(value = "elementID") String destinationId) throws IOException, PortalException { final Locale locale = RequestContextUtils.getLocale(request); if (moveElementInternal(request, sourceId, destinationId, method)) { return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage( "success.move.element", "Element moved successfully", locale))); } else { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage("error.move.element", "Error moving element", locale))); } }
UpdatePreferencesServlet { @RequestMapping(method = RequestMethod.POST, params = "action=moveElement") public ModelAndView moveElement( HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "sourceID") String sourceId, @RequestParam String method, @RequestParam(value = "elementID") String destinationId) throws IOException, PortalException { final Locale locale = RequestContextUtils.getLocale(request); if (moveElementInternal(request, sourceId, destinationId, method)) { return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage( "success.move.element", "Element moved successfully", locale))); } else { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage("error.move.element", "Error moving element", locale))); } } }
UpdatePreferencesServlet { @RequestMapping(method = RequestMethod.POST, params = "action=moveElement") public ModelAndView moveElement( HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "sourceID") String sourceId, @RequestParam String method, @RequestParam(value = "elementID") String destinationId) throws IOException, PortalException { final Locale locale = RequestContextUtils.getLocale(request); if (moveElementInternal(request, sourceId, destinationId, method)) { return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage( "success.move.element", "Element moved successfully", locale))); } else { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage("error.move.element", "Error moving element", locale))); } }  }
UpdatePreferencesServlet { @RequestMapping(method = RequestMethod.POST, params = "action=moveElement") public ModelAndView moveElement( HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "sourceID") String sourceId, @RequestParam String method, @RequestParam(value = "elementID") String destinationId) throws IOException, PortalException { final Locale locale = RequestContextUtils.getLocale(request); if (moveElementInternal(request, sourceId, destinationId, method)) { return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage( "success.move.element", "Element moved successfully", locale))); } else { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage("error.move.element", "Error moving element", locale))); } }  @Autowired void setUserLayoutStore(IUserLayoutStore userLayoutStore); @Autowired void setStylesheetUserPreferencesService(
            IStylesheetUserPreferencesService stylesheetUserPreferencesService); @Autowired void setPortletDefinitionRegistry(IPortletDefinitionRegistry portletDefinitionRegistry); @Autowired void setUserIdentityStore(IUserIdentityStore userStore); @Autowired void setUserInstanceManager(IUserInstanceManager userInstanceManager); @Autowired void setMessageSource(MessageSource messageSource); @Autowired void setPortletWindowRegistry(IPortletWindowRegistry portletWindowRegistry); @Autowired void setFavoritesUtils(FavoritesUtils favoritesUtils); @RequestMapping(method = RequestMethod.POST, params = "action=removeElement") ModelAndView removeElement(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=removeByFName") ModelAndView removeByFName(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "fname") String fname); @RequestMapping(method = RequestMethod.POST, params = "action=movePortletAjax") ModelAndView movePortletAjax(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam String sourceId,
            @RequestParam String previousNodeId,
            @RequestParam String nextNodeId); @RequestMapping(method = RequestMethod.POST, params = "action=movePortlet") @Deprecated ModelAndView movePortlet(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "sourceID") String sourceId,
            @RequestParam String method,
            @RequestParam(value = "elementID") String destinationId); @RequestMapping(method = RequestMethod.POST, params = "action=moveElement") ModelAndView moveElement(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "sourceID") String sourceId,
            @RequestParam String method,
            @RequestParam(value = "elementID") String destinationId); @RequestMapping(method = RequestMethod.POST, params = "action=changeColumns") ModelAndView changeColumns(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam("tabId") String tabId,
            @RequestParam("widths[]") String[] widths,
            @RequestParam(value = "deleted[]", required = false) String[] deleted,
            @RequestParam(value = "acceptor", required = false) String acceptor); @RequestMapping(method = RequestMethod.POST, params = "action=moveTab") ModelAndView moveTab(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "sourceID") String sourceId,
            @RequestParam String method,
            @RequestParam(value = "elementID") String destinationId); @RequestMapping(method = RequestMethod.POST, params = "action=addFavorite") ModelAndView addFavorite(
            @RequestParam String channelId,
            HttpServletRequest request,
            HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=removeFavorite") ModelAndView removeFavorite(
            @RequestParam String channelId,
            HttpServletRequest request,
            HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=addPortlet") ModelAndView addPortlet(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=chooseSkin") ModelAndView chooseSkin(HttpServletRequest request, @RequestParam String skinName); @RequestMapping(method = RequestMethod.POST, params = "action=addTab") ModelAndView addTab(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam("widths[]") String[] widths); @RequestMapping(method = RequestMethod.POST, params = "action=addFolder") ModelAndView addFolder(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam("targetId") String targetId,
            @RequestParam(value = "siblingId", required = false) String siblingId,
            @RequestBody(required = false) Map<String, Map<String, String>> attributes); @RequestMapping(method = RequestMethod.POST, params = "action=updateAttributes") ModelAndView updateAttributes(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam("targetId") String targetId,
            @RequestBody Map<String, Map<String, String>> attributes); @RequestMapping(method = RequestMethod.POST, params = "action=renameTab") ModelAndView renameTab(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=updatePermissions") ModelAndView updatePermissions(HttpServletRequest request, HttpServletResponse response); }
UpdatePreferencesServlet { @RequestMapping(method = RequestMethod.POST, params = "action=moveElement") public ModelAndView moveElement( HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "sourceID") String sourceId, @RequestParam String method, @RequestParam(value = "elementID") String destinationId) throws IOException, PortalException { final Locale locale = RequestContextUtils.getLocale(request); if (moveElementInternal(request, sourceId, destinationId, method)) { return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage( "success.move.element", "Element moved successfully", locale))); } else { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return new ModelAndView( "jsonView", Collections.singletonMap( "response", getMessage("error.move.element", "Error moving element", locale))); } }  @Autowired void setUserLayoutStore(IUserLayoutStore userLayoutStore); @Autowired void setStylesheetUserPreferencesService(
            IStylesheetUserPreferencesService stylesheetUserPreferencesService); @Autowired void setPortletDefinitionRegistry(IPortletDefinitionRegistry portletDefinitionRegistry); @Autowired void setUserIdentityStore(IUserIdentityStore userStore); @Autowired void setUserInstanceManager(IUserInstanceManager userInstanceManager); @Autowired void setMessageSource(MessageSource messageSource); @Autowired void setPortletWindowRegistry(IPortletWindowRegistry portletWindowRegistry); @Autowired void setFavoritesUtils(FavoritesUtils favoritesUtils); @RequestMapping(method = RequestMethod.POST, params = "action=removeElement") ModelAndView removeElement(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=removeByFName") ModelAndView removeByFName(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "fname") String fname); @RequestMapping(method = RequestMethod.POST, params = "action=movePortletAjax") ModelAndView movePortletAjax(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam String sourceId,
            @RequestParam String previousNodeId,
            @RequestParam String nextNodeId); @RequestMapping(method = RequestMethod.POST, params = "action=movePortlet") @Deprecated ModelAndView movePortlet(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "sourceID") String sourceId,
            @RequestParam String method,
            @RequestParam(value = "elementID") String destinationId); @RequestMapping(method = RequestMethod.POST, params = "action=moveElement") ModelAndView moveElement(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "sourceID") String sourceId,
            @RequestParam String method,
            @RequestParam(value = "elementID") String destinationId); @RequestMapping(method = RequestMethod.POST, params = "action=changeColumns") ModelAndView changeColumns(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam("tabId") String tabId,
            @RequestParam("widths[]") String[] widths,
            @RequestParam(value = "deleted[]", required = false) String[] deleted,
            @RequestParam(value = "acceptor", required = false) String acceptor); @RequestMapping(method = RequestMethod.POST, params = "action=moveTab") ModelAndView moveTab(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam(value = "sourceID") String sourceId,
            @RequestParam String method,
            @RequestParam(value = "elementID") String destinationId); @RequestMapping(method = RequestMethod.POST, params = "action=addFavorite") ModelAndView addFavorite(
            @RequestParam String channelId,
            HttpServletRequest request,
            HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=removeFavorite") ModelAndView removeFavorite(
            @RequestParam String channelId,
            HttpServletRequest request,
            HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=addPortlet") ModelAndView addPortlet(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=chooseSkin") ModelAndView chooseSkin(HttpServletRequest request, @RequestParam String skinName); @RequestMapping(method = RequestMethod.POST, params = "action=addTab") ModelAndView addTab(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam("widths[]") String[] widths); @RequestMapping(method = RequestMethod.POST, params = "action=addFolder") ModelAndView addFolder(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam("targetId") String targetId,
            @RequestParam(value = "siblingId", required = false) String siblingId,
            @RequestBody(required = false) Map<String, Map<String, String>> attributes); @RequestMapping(method = RequestMethod.POST, params = "action=updateAttributes") ModelAndView updateAttributes(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam("targetId") String targetId,
            @RequestBody Map<String, Map<String, String>> attributes); @RequestMapping(method = RequestMethod.POST, params = "action=renameTab") ModelAndView renameTab(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.POST, params = "action=updatePermissions") ModelAndView updatePermissions(HttpServletRequest request, HttpServletResponse response);  }