@Test public void testSubmitAddUserForm() throws Exception { setUpMockRoleDataService(); setUpMockUserDataService(true, false, false); setUpMockAuthenticationContext(); CreateUserCommand createUserCommand = createUserCommandFactory.getNewCreateUserCommand(); createUserCommand.setSiteUrl("http: createUserCommand.setEmail("newUser@test.com"); createUserCommand.setPassword("P4sSw0rD"); createUserCommand.setConfirmPassword("P4sSw0rD"); BindingResult bindingResult = new BeanPropertyBindingResult(createUserCommand,"createUserCommand"); Model model = new ExtendedModelMap(); String result = instance.submitAddUserForm(createUserCommand, bindingResult, model); assertEquals(ADMIN_VIEW_NAME, result); assertFalse(bindingResult.hasErrors()); assertTrue(bindingResult.getFieldErrors().isEmpty()); assertEquals(2, model.asMap().size()); assertEquals("newUser@test.com",model.asMap().get(ADDED_USER_NAME_KEY)); assertTrue(((List<User>)model.asMap().get(TgolKeyStore.USER_LIST_KEY)).isEmpty()); }
@RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.POST) protected String submitAddUserForm( @ModelAttribute(TgolKeyStore.CREATE_USER_COMMAND_KEY) CreateUserCommand createUserCommand, BindingResult result, Model model) throws Exception { return submitCreateUserForm( createUserCommand, result, model, TgolKeyStore.ADMIN_VIEW_NAME, TgolKeyStore.ADD_USER_VIEW_NAME, TgolKeyStore.ADDED_USER_NAME_KEY); }
UserManagementController extends AbstractUserAndContractsController { @RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.POST) protected String submitAddUserForm( @ModelAttribute(TgolKeyStore.CREATE_USER_COMMAND_KEY) CreateUserCommand createUserCommand, BindingResult result, Model model) throws Exception { return submitCreateUserForm( createUserCommand, result, model, TgolKeyStore.ADMIN_VIEW_NAME, TgolKeyStore.ADD_USER_VIEW_NAME, TgolKeyStore.ADDED_USER_NAME_KEY); } }
UserManagementController extends AbstractUserAndContractsController { @RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.POST) protected String submitAddUserForm( @ModelAttribute(TgolKeyStore.CREATE_USER_COMMAND_KEY) CreateUserCommand createUserCommand, BindingResult result, Model model) throws Exception { return submitCreateUserForm( createUserCommand, result, model, TgolKeyStore.ADMIN_VIEW_NAME, TgolKeyStore.ADD_USER_VIEW_NAME, TgolKeyStore.ADDED_USER_NAME_KEY); } UserManagementController(ContractDataService contractDataService,
                                    CreateUserCommandFactory createUserCommandFactory); }
UserManagementController extends AbstractUserAndContractsController { @RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.POST) protected String submitAddUserForm( @ModelAttribute(TgolKeyStore.CREATE_USER_COMMAND_KEY) CreateUserCommand createUserCommand, BindingResult result, Model model) throws Exception { return submitCreateUserForm( createUserCommand, result, model, TgolKeyStore.ADMIN_VIEW_NAME, TgolKeyStore.ADD_USER_VIEW_NAME, TgolKeyStore.ADDED_USER_NAME_KEY); } UserManagementController(ContractDataService contractDataService,
                                    CreateUserCommandFactory createUserCommandFactory); @RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.EDIT_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayEditUserAdminPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAddUserAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserConfirmation(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_AUDITS_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserAuditsPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_AUDITS_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserAuditsConfirmationPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_CONTRACT_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAddContractAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_CONTRACT_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String submitAddContractAdminPage(
            @ModelAttribute(TgolKeyStore.CREATE_CONTRACT_COMMAND_KEY) CreateContractCommand ccc,
            BindingResult result,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); }
UserManagementController extends AbstractUserAndContractsController { @RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.POST) protected String submitAddUserForm( @ModelAttribute(TgolKeyStore.CREATE_USER_COMMAND_KEY) CreateUserCommand createUserCommand, BindingResult result, Model model) throws Exception { return submitCreateUserForm( createUserCommand, result, model, TgolKeyStore.ADMIN_VIEW_NAME, TgolKeyStore.ADD_USER_VIEW_NAME, TgolKeyStore.ADDED_USER_NAME_KEY); } UserManagementController(ContractDataService contractDataService,
                                    CreateUserCommandFactory createUserCommandFactory); @RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.EDIT_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayEditUserAdminPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAddUserAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserConfirmation(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_AUDITS_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserAuditsPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_AUDITS_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserAuditsConfirmationPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_CONTRACT_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAddContractAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_CONTRACT_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String submitAddContractAdminPage(
            @ModelAttribute(TgolKeyStore.CREATE_CONTRACT_COMMAND_KEY) CreateContractCommand ccc,
            BindingResult result,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model);  }