Package org.springframework.ui

Examples of org.springframework.ui.ModelMap


    @Test(expected = SecurityException.class)
    public void updateWidget_wrongToken() {
        WidgetImpl widget = new WidgetImpl();
        BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        ModelMap modelMap = new ExtendedModelMap();

        sessionStatus.setComplete();
        expectLastCall();
        replay(sessionStatus);
View Full Code Here


    @Test
    public void updateWidget_invalid() {
        WidgetImpl widget = new WidgetImpl(123L, "http://broken/url");
        BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        ModelMap modelMap = new ExtendedModelMap();

        String view = controller.updateWidgetDetail(widget, errors, validToken, validToken, modelMap, sessionStatus);

        assertTrue("Errors", errors.hasErrors());
        assertEquals(ViewNames.ADMIN_WIDGETDETAIL, view);
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";
        UserImpl user = new UserImpl(userid, "john.doe.sr");
        user.setPassword("secrect");
        user.setConfirmPassword("secrect");
View Full Code Here

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

    @Test
    public void updateUserDetail_withErrors() {
        ModelMap modelMap = new ExtendedModelMap();
        Long userid = 123L;
        UserImpl user = new UserImpl(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();
        UserImpl user = new UserImpl(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 UserImpl(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 UserImpl(userid, "john.doe.sr");

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

        assertEquals(ViewNames.ADMIN_USERDETAIL, view);
    }

    @Test(expected = SecurityException.class)
    public void deleteUserDetail_wrongToken() {
        ModelMap modelMap = new ExtendedModelMap();
        User user = new UserImpl(123L, "john.doe.sr");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        sessionStatus.setComplete();

        expectLastCall();
View Full Code Here

    }

    @Test
    public void setupForm() {
        ModelMap modelMap = new ExtendedModelMap();
        final String viewName = controller.setUpForm(modelMap);
        assertEquals(ViewNames.ADMIN_NEW_ACCOUNT, viewName);
        assertTrue(modelMap.containsAttribute(TABS));
        assertTrue(modelMap.get(ModelKeys.NEW_USER) instanceof UserImpl);
    }
View Full Code Here

  @Test
  public void viewPerson_ShouldAddAttributeForUser() {
    //creating a mock user
    final UserImpl user = new UserImpl();
    final ModelMap model = new ModelMap();
    final int modelSize = 4;
    final String username="canonical";
        user.setUsername(username);
        user.setId(USER_ID);
    String userProfile = new String(ModelKeys.USER_PROFILE);
        Page personProfile = new PageImpl();
        PageLayout pageLayout = new PageLayoutImpl();
        pageLayout.setCode(VALID_PAGE_LAYOUT_CODE);
        personProfile.setPageLayout(pageLayout);
        List<Person> personObjects = new ArrayList<Person>();

    expect(userService.getUserByUsername(username)).andReturn(user).once();
        expect(pageService.getPersonProfilePage(user.getId())).andReturn(personProfile);
    expect(userService.getFriendRequestsReceived(username)).andReturn(personObjects);

    replay(userService, pageService);

    String view = profileController.viewProfile(username, model, null);

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

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

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

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

        assertThat(view, is(ViewNames.PERSON_PROFILE + "." + VALID_PAGE_LAYOUT_CODE));

    verify(userService, pageService);
  }
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.