Package org.springframework.ui

Examples of org.springframework.ui.Model


    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("", 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));
    }
View Full Code Here


    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, 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"));
    }
View Full Code Here

    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, 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"));
    }
View Full Code Here

    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, 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"));
    }
View Full Code Here

        assertTrue(model.containsAttribute("tabs"));
    }

    @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, model, sessionStatus);
        assertEquals("ViewName match", "redirect:/app/admin/categories?action=create", view);
        assertTrue("empty model", model.asMap().isEmpty());
        verify(userService, categoryService, sessionStatus);
    }
View Full Code Here

        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

        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, model, sessionStatus);
        assertEquals("ViewName match", ViewNames.ADMIN_CATEGORIES, view);
        assertFalse("empty model", model.asMap().isEmpty());
        verify(userService);
    }
View Full Code Here

        verify(userService);
    }

    @Test
    public void updateCategory_valid(){
        Model model = new ExtendedModelMap();
        User user = new UserImpl();
        long id = 1L;
        String categoryText = "Social";
        CategoryImpl category = new CategoryImpl();
        category.setCreatedUser(user);
        category.setText(categoryText);
        category.setId(id);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        expect(categoryService.get(id)).andReturn(category);
        expect(categoryService.update(id, categoryText, user)).andReturn(category);
        sessionStatus.setComplete();
        expectLastCall();
        replay(userService, categoryService,sessionStatus);
        String view = controller.updateCategory(category, validToken, validToken, model, sessionStatus);
        assertEquals("ViewName match", "redirect:/app/admin/categories?action=update", view);
        assertTrue("empty model", model.asMap().isEmpty());
        verify(userService, categoryService, sessionStatus);
    }
View Full Code Here

        verify(userService, categoryService, sessionStatus);
    }

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

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

    @Test
    public void updateCategory_invalidValidRequest_emptyText(){
        Model model = new ExtendedModelMap();
        User user = new UserImpl();

        long id = 1L;
        String categoryText = "";
        CategoryImpl category = new CategoryImpl();
        category.setCreatedUser(user);
        category.setText(categoryText);
        category.setId(id);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        replay(userService);
        String view = controller.updateCategory(category, validToken, validToken, model, sessionStatus);
        assertEquals("ViewName match", ViewNames.ADMIN_CATEGORY_DETAIL, view);
        assertFalse("empty model", model.asMap().isEmpty());
        verify(userService);
    }
View Full Code Here

TOP

Related Classes of org.springframework.ui.Model

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.