Package org.springframework.ui

Examples of org.springframework.ui.ModelMap


    }

  @Test
  public void updateProfile_ShouldUpdateAuthenticatedUser() {
    //This test will just show the successful updation of user status
    final ModelMap model = new ModelMap();
    final int modelSize = 2;
    final long referringPageId = 1L;
        final String USERNAME = "canonical";
    String userProfile = new String(ModelKeys.USER_PROFILE);

    //creating a mock authenticated user
    final User authUser = new UserImpl();
        authUser.setUsername(USERNAME);
    //set existing status
    authUser.setStatus("Single");
    //set other paramters
    authUser.setGivenName("Test");
    authUser.setFamilyName("Rave");
    authUser.setAboutMe("Test User");
    authUser.setEmail("testuser@rave.com");

    //creating a mock updated user
    final UserForm updatedUser = new UserForm();
    //set the updated status
    updatedUser.setStatus("Married");
    updatedUser.setGivenName("Test");
    updatedUser.setFamilyName("Rave");
    updatedUser.setAboutMe("Test User");
    updatedUser.setEmail("testuser@rave.com");

    expect(userService.getAuthenticatedUser()).andReturn(authUser).anyTimes();
    userService.updateUserProfile(authUser);
    replay(userService);

    String view = profileController.updateProfile(model, referringPageId, updatedUser);

    //assert that the model is not null
    assertThat(model, CoreMatchers.notNullValue());

    //assert that the model size is three
    assertThat(model.size(), CoreMatchers.equalTo(modelSize));

    //assert that the model does contain an attribute associated with the authenticated user
    assertThat(model.containsAttribute(userProfile), CoreMatchers.equalTo(true));

    //assert that the model does not contain authenticated user as null
    assertThat(model.get(userProfile), CoreMatchers.notNullValue());

    //assert that the status of user is updated
    assertEquals(updatedUser.getStatus(), authUser.getStatus());

        assertThat(view, is("redirect:/app/person/" + USERNAME));
View Full Code Here


  /**
   * Return the underlying <code>ModelMap</code> instance (never <code>null</code>).
   */
  public ModelMap getModelMap() {
    if (this.model == null) {
      this.model = new ModelMap();
    }
    return this.model;
  }
View Full Code Here

    return "treatmentdetails";
  }
  @RequestMapping("treatment_details")
  public String showTreatmentDetails(Map model)
  {
    ModelMap modelMap = new ModelMap();
    System.out.println("in showTreatmentDetails()");
   
    //modelMap.addAttribute("treatment_details", myUserDAO.Channel_list());
    //System.out.println("in showTreatmentDetails method"+treatment_details.s);
    //myUserDAO.Channel_list();
View Full Code Here

    return "Treatement_Detailes";
  }
  @RequestMapping("Channel_details")
  public String showChannelDetails(Map model)
  {
    ModelMap modelMap = new ModelMap();
    System.out.println("in showChannelDetails()");
   
    //modelMap.addAttribute("treatment_details", myUserDAO.Channel_list());
    //System.out.println("in showTreatmentDetails method"+treatment_details.s);
    //myUserDAO.Channel_list();
View Full Code Here

    newAccountController = new NewAccountController(newAccountService, newAccountValidator, captchaService);
  }
 
  @Test
  public void setUpForm_ShouldAddAttributeForNewUser() {
    final ModelMap model = new ModelMap();
    String newUser = new String(ModelKeys.NEW_USER);
    newAccountController.setUpForm(model, request);
   
    //assert that the model is not null
    assertThat(model, CoreMatchers.notNullValue());
   
    //assert that the model size is two
    assertThat(model.size(), CoreMatchers.equalTo(2));
   
    //assert that the model does contain an attribute associated with newUser after setUpForm() is called
    assertThat(model.containsAttribute(newUser), CoreMatchers.equalTo(true));
   
    //assert that the model does not contain new user as null
    assertThat(model.get(newUser), CoreMatchers.notNullValue());
  }
View Full Code Here

    }


    @Test
    public void updateUserDetail_success() {
        ModelMap modelMap = new ExtendedModelMap();
        final Long userid = 123L;
        final String email = "john.doe.sr@example.net";
        User user = new User(userid, "john.doe.sr");
        user.setPassword("secrect");
        user.setConfirmPassword(user.getConfirmPassword());
View Full Code Here

        assertEquals("redirect:/app/admin/users?action=update", view);
    }

    @Test
    public void updateUserDetail_withErrors() {
        ModelMap modelMap = new ExtendedModelMap();
        Long userid = 123L;
        User user = new User(userid, "john.doe.sr");
        final BindingResult errors = new BeanPropertyBindingResult(user, "user");

        SessionStatus sessionStatus = createMock(SessionStatus.class);
View Full Code Here

        assertEquals(ViewNames.ADMIN_USERDETAIL, view);
    }

    @Test(expected = SecurityException.class)
    public void updateUserDetail_wrongToken() {
        ModelMap modelMap = new ExtendedModelMap();
        User user = new User(123L, "john.doe.sr");
        final BindingResult errors = new BeanPropertyBindingResult(user, "user");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        sessionStatus.setComplete();
View Full Code Here

        assertFalse("SecurityException", true);

    }
    @Test
    public void deleteUserDetail_success() {
        ModelMap modelMap = new ExtendedModelMap();
        final Long userid = 123L;
        final String email = "john.doe.sr@example.net";
        User user = new User(userid, "john.doe.sr");
        user.setPassword("secrect");
        user.setConfirmPassword(user.getConfirmPassword());
View Full Code Here

        assertEquals("redirect:/app/admin/users?action=delete", view);
    }

    @Test
    public void deleteUserDetail_noConfirmChecked() {
        ModelMap modelMap = new ExtendedModelMap();
        Long userid = 123L;
        User user = new User(userid, "john.doe.sr");

        SessionStatus sessionStatus = createMock(SessionStatus.class);
        replay(sessionStatus);
View Full Code Here

TOP

Related Classes of org.springframework.ui.ModelMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.