Package org.springframework.ui

Examples of org.springframework.ui.ModelMap


    }

    @Test
    public void showForm() throws Exception {
        controller.setServletContext(new MockServletContext());
        assertEquals("No jsp in WEB-INF", "crud/template", controller.showForm("stubs.TrivialDomainEntity", null, null, new ModelMap(), new MockHttpSession()));
        controller.setServletContext(new MockServletContext("web", new FileSystemResourceLoader()));
        assertEquals("JSP in WEB-INF", "crud/demoapp/domain/book", controller.showForm("demoapp.domain.Book", null, null, new ModelMap(), new MockHttpSession()));
    }
View Full Code Here


    newAccountController = new NewAccountController(newAccountService, newAccountValidator, captchaService);
  }

  @Test
  public void setUpForm_ShouldAddAttributeForUser() {
    final ModelMap model = new ModelMap();
    String User = 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 User after setUpForm() is called
    assertThat(model.containsAttribute(User), CoreMatchers.equalTo(true));

    //assert that the model does not contain new user as null
    assertThat(model.get(User), CoreMatchers.notNullValue());
  }
View Full Code Here

    }


    @Test
    public void updateUserDetail_success() {
        ModelMap modelMap = new ExtendedModelMap();
        String userid = "123";
        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

    }

    @Test
    public void updateUserDetail_withErrors() {
        ModelMap modelMap = new ExtendedModelMap();
        String userid = "123";
        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("123", "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();
        String userid = "123";
        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

    }

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

        SessionStatus sessionStatus = createMock(SessionStatus.class);
        replay(sessionStatus);
        final String view = controller.deleteUserDetail(user, validToken, validToken, null,REFERRER_ID, modelMap, sessionStatus);
        verify(sessionStatus);

        assertEquals(ViewNames.ADMIN_USERDETAIL, view);
        assertThat((String) modelMap.get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
    }
View Full Code Here

        assertThat((String) modelMap.get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
    }

    @Test(expected = SecurityException.class)
    public void deleteUserDetail_wrongToken() {
        ModelMap modelMap = new ExtendedModelMap();
        User user = new UserImpl("123", "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,REFERRER_ID);
        assertEquals(ViewNames.ADMIN_NEW_ACCOUNT, viewName);
        assertTrue(modelMap.containsAttribute(TABS));
        assertTrue(modelMap.get(ModelKeys.NEW_USER) instanceof UserImpl);
        assertThat((String) modelMap.get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
    }
View Full Code Here

        assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
    }

    @Test
    public void testUpdatePreferences_valid() {
        ModelMap model = new ExtendedModelMap();
        PortalPreferenceForm form = new PortalPreferenceForm(new HashMap<String, PortalPreference>());
        final BindingResult errors = new BeanPropertyBindingResult(form, "form");
        SessionStatus sessionStatus = createMock(SessionStatus.class);

        final Set<Map.Entry<String, PortalPreference>> entries = form.getPreferenceMap().entrySet();

        for (Map.Entry<String, PortalPreference> entry : entries) {
            service.savePreference(entry.getValue());
        }
        sessionStatus.setComplete();

        expectLastCall();
        replay(service, sessionStatus);
        String view = controller.updatePreferences(form, errors, validToken, validToken,REFERRER_ID, model, sessionStatus);

        assertEquals("redirect:/app/admin/preferences?action=update&referringPageId=" + REFERRER_ID, view);
        assertTrue("Model has been cleared", model.isEmpty());

        verify(service, 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.