Examples of ExtendedModelMap


Examples of org.springframework.ui.ExtendedModelMap

    @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

Examples of org.springframework.ui.ExtendedModelMap

    @Test
    public void updateWidget_invalid() {
        WidgetImpl widget = new WidgetImpl("123", "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,REFERRER_ID, modelMap, sessionStatus);

        assertTrue("Errors", errors.hasErrors());
        assertEquals(ViewNames.ADMIN_WIDGETDETAIL, view);
View Full Code Here

Examples of org.springframework.ui.ExtendedModelMap

        userService = createMock(UserService.class);
        pageService = createMock(PageService.class);
        pageLayoutService = createMock(PageLayoutService.class);
        pageController = new PageController(pageService, userService, pageLayoutService);
        model = new ExtendedModelMap();
        request = new MockHttpServletRequest();

        validUser = new UserImpl(USER_ID);
        validPageLayout = new PageLayoutImpl();
        validPageLayout.setCode(VALID_PAGE_LAYOUT_CODE);
View Full Code Here

Examples of org.springframework.ui.ExtendedModelMap

    public void getCategories_valid(){
        List<Category> categories = new ArrayList<Category>();
        expect(categoryService.getAll()).andReturn(categories);
        replay(categoryService);

        Model model = new ExtendedModelMap();

        String viewName = controller.getCategories("",REFERRER_ID, model);
        verify(categoryService);

        assertEquals(ViewNames.ADMIN_CATEGORIES, viewName);
        assertEquals(categories, model.asMap().get("categories"));
        assertFalse(model.containsAttribute("actionresult"));
        assertTrue(model.containsAttribute("category"));
        assertEquals("Check that the category object available", new CategoryImpl(), model.asMap().get("category"));
        assertTrue(model.containsAttribute("topnav"));
        assertTrue(model.containsAttribute("tabs"));
        assertTrue("verify tokencheck", model.asMap().containsKey(ModelKeys.TOKENCHECK));
        assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
    }
View Full Code Here

Examples of org.springframework.ui.ExtendedModelMap

    public void getCategory_valid_update() {
        List<Category> categories = new ArrayList<Category>();
        expect(categoryService.getAll()).andReturn(categories);
        replay(categoryService);

        Model model = new ExtendedModelMap();

        String viewName = controller.getCategories(UPDATE,REFERRER_ID, model);
        verify(categoryService);

        assertEquals(ViewNames.ADMIN_CATEGORIES, viewName);
        assertEquals(categories, model.asMap().get("categories"));
        assertTrue(model.containsAttribute("actionresult"));
        assertEquals(UPDATE, model.asMap().get("actionresult"));
        assertTrue(model.containsAttribute("category"));
        assertEquals("Check that the category object available", new CategoryImpl(), model.asMap().get("category"));
        assertTrue(model.containsAttribute("topnav"));
        assertTrue(model.containsAttribute("tabs"));
        assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
    }
View Full Code Here

Examples of org.springframework.ui.ExtendedModelMap

    public void getCategory_valid_delete(){
        List<Category> categories = new ArrayList<Category>();
        expect(categoryService.getAll()).andReturn(categories);
        replay(categoryService);

        Model model = new ExtendedModelMap();

        String viewName = controller.getCategories(DELETE,REFERRER_ID, model);
        verify(categoryService);

        assertEquals(ViewNames.ADMIN_CATEGORIES, viewName);
        assertEquals(categories, model.asMap().get("categories"));
        assertTrue(model.containsAttribute("actionresult"));
        assertEquals(DELETE, model.asMap().get("actionresult"));
        assertTrue(model.containsAttribute("category"));
        assertEquals("Check that the category object available", new CategoryImpl(), model.asMap().get("category"));
        assertTrue(model.containsAttribute("topnav"));
        assertTrue(model.containsAttribute("tabs"));
        assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
    }
View Full Code Here

Examples of org.springframework.ui.ExtendedModelMap

    public void getCategory_valid_create(){
        List<Category> categories = new ArrayList<Category>();
        expect(categoryService.getAll()).andReturn(categories);
        replay(categoryService);

        Model model = new ExtendedModelMap();

        String viewName = controller.getCategories(CREATE,REFERRER_ID, model);
        verify(categoryService);

        assertEquals(ViewNames.ADMIN_CATEGORIES, viewName);
        assertEquals(categories, model.asMap().get("categories"));
        assertTrue(model.containsAttribute("actionresult"));
        assertEquals(CREATE, model.asMap().get("actionresult"));
        assertTrue(model.containsAttribute("category"));
        assertEquals("Check category object available", new CategoryImpl(), model.asMap().get("category"));
        assertTrue(model.containsAttribute("topnav"));
        assertTrue(model.containsAttribute("tabs"));
        assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
    }
View Full Code Here

Examples of org.springframework.ui.ExtendedModelMap

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

    @Test
    public void createCategory_valid(){
        Model model = new ExtendedModelMap();
        User user = new UserImpl();
        String categoryText = "Social";
        CategoryImpl category = new CategoryImpl();
        category.setText(categoryText);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        expect(categoryService.create(categoryText, user)).andReturn(new CategoryImpl());
        sessionStatus.setComplete();
        expectLastCall();
        replay(userService, categoryService,sessionStatus);
        String view = controller.createCategory(category, validToken, validToken,REFERRER_ID, model, sessionStatus);
        assertEquals("ViewName match", "redirect:/app/admin/categories?action=create&referringPageId=" +REFERRER_ID, view);
        assertTrue("empty model", model.asMap().isEmpty());
        verify(userService, categoryService, sessionStatus);
    }
View Full Code Here

Examples of org.springframework.ui.ExtendedModelMap

        verify(userService, categoryService, sessionStatus);
    }

    @Test(expected = SecurityException.class)
    public void createCategory_invalidToken(){
        Model model = new ExtendedModelMap();
        String invalidToken =  AdminControllerUtil.generateSessionToken();
        User user = new UserImpl();
        String categoryText = "Social";
        CategoryImpl category = new CategoryImpl();
        category.setText(categoryText);
View Full Code Here

Examples of org.springframework.ui.ExtendedModelMap

        assertTrue("Test should catch exception and never hit this test", false);
    }

    @Test
    public void createCategory_invalidValidRequest_emptyText(){
        Model model = new ExtendedModelMap();
        User user = new UserImpl();
        String categoryText = "";
        CategoryImpl category = new CategoryImpl();
        category.setText(categoryText);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        replay(userService);
        String view = controller.createCategory(category, validToken, validToken,REFERRER_ID, model, sessionStatus);
        assertEquals("ViewName match", ViewNames.ADMIN_CATEGORIES, view);
        assertFalse("empty model", model.asMap().isEmpty());
        verify(userService);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.