Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.SimplePage


     * @return {@code ModelAndView}     object with 'simplePage' view with data from {@link SimplePageDto}
     */
    @RequestMapping(value = "/pages/{pagePathName}", method = RequestMethod.GET)
    public ModelAndView showPage(@PathVariable(PAGE_PATH_NAME) String pagePathName) {
        checkPermissionToCreateAndEditPage();
        SimplePage page = null;
        try {
            page = simplePageService.getPageByPathName(pagePathName);
        } finally {
            if (page != null) {
                SimplePageDto pageDto = new SimplePageDto(page);
View Full Code Here


     * @throws NotFoundException when page was not found or not exist
     */
    @RequestMapping(value = "/pages/{pagePathName}/edit", method = RequestMethod.GET)
    public ModelAndView showEditPage(@PathVariable(PAGE_PATH_NAME) String pagePathName) throws NotFoundException {
        checkPermissionToCreateAndEditPage();
        SimplePage page = simplePageService.getPageByPathName(pagePathName);

        SimplePageDto pageDto = new SimplePageDto(page);

        return new ModelAndView("simplePageEditor")
                .addObject(PAGE_DTO, pageDto);
View Full Code Here

        return new ModelAndView("redirect:/pages/" + pagePathName);
    }

    @RequestMapping(value = "/pages/create/{pagePathName}", method = RequestMethod.GET)
    public ModelAndView createPage(@PathVariable(PAGE_PATH_NAME) String pagePathName) {
        SimplePage simplePage = new SimplePage();
        simplePage.setName("Title");
        simplePage.setContent("Content");
        simplePage.setPathName(pagePathName);

        JCUser userCreator = userService.getCurrentUser();
        simplePageService.createPage(simplePage, userCreator);
        SimplePageDto simplePageDto = new SimplePageDto(simplePage);
View Full Code Here

    /*===== Common methods =====*/

    @Test
    public void testGet() {
        SimplePage simplePage = ObjectsFactory.getDefaultSimplePage();
        session.save(simplePage);

        SimplePage result = dao.get(simplePage.getId());

        assertNotNull(result);
        assertEquals(result.getId(), simplePage.getId());
        assertEquals(result.getName(), simplePage.getName());
        assertEquals(result.getContent(), simplePage.getContent());
        assertEquals(result.getPathName(), simplePage.getPathName());
    }
View Full Code Here

        assertEquals(result.getPathName(), simplePage.getPathName());
    }

    @Test
    public void testGetInvalidId() {
        SimplePage simplePage = dao.get(-567890L);
        assertNull(simplePage);
    }
View Full Code Here

    @Test
    public void testUpdate() {
        String newName = "newName";
        String newContent = "newContent";
        SimplePage simplePage = ObjectsFactory.getDefaultSimplePage();
        session.save(simplePage);

        simplePage.setName(newName);
        simplePage.setContent(newContent);

        dao.saveOrUpdate(simplePage);
        session.flush();
        session.evict(simplePage);
        SimplePage result = (SimplePage) session.get(SimplePage.class, simplePage.getId());

        assertEquals(result.getName(), newName);
        assertEquals(result.getContent(), newContent);
    }
View Full Code Here

        assertEquals(result.getContent(), newContent);
    }

    @Test
    public void testIsExist() {
        SimplePage simplePage = ObjectsFactory.getDefaultSimplePage();
        session.save(simplePage);
        assertTrue(dao.isExist(simplePage.getId()));
    }
View Full Code Here

    /* SimplePageHibernateDao specific methods */

    @Test
    public void testCreatePage() {
        SimplePage simplePage = ObjectsFactory.getDefaultSimplePage();
        session.save(simplePage);

        dao.createPage(simplePage);
        session.evict(simplePage);
        SimplePage result = (SimplePage) session.get(SimplePage.class, simplePage.getId());

        assertNotNull(result);
        assertEquals(simplePage.getId(), result.getId());
        assertEquals(simplePage.getName(), result.getName());
        assertEquals(simplePage.getContent(), result.getContent());
        assertEquals(simplePage.getPathName(), result.getPathName());
    }
View Full Code Here

        assertEquals(simplePage.getPathName(), result.getPathName());
    }

    @Test
    public void testGetPageByPathName() {
        SimplePage simplePage = ObjectsFactory.getDefaultSimplePage();
        session.save(simplePage);

        SimplePage result = dao.getPageByPathName(simplePage.getPathName());

        assertNotNull(result);
        assertEquals(simplePage.getId(), result.getId());
        assertEquals(simplePage.getName(), result.getName());
        assertEquals(simplePage.getContent(), result.getContent());
        assertEquals(simplePage.getPathName(), result.getPathName());
    }
View Full Code Here

        assertEquals(simplePage.getPathName(), result.getPathName());
    }

    @Test
    public void testGetPageByPathNameNotExist() {
        SimplePage simplePage = ObjectsFactory.getDefaultSimplePage();
        session.save(simplePage);

        SimplePage result = dao.getPageByPathName("not Exist Path Name");

        assertNull(result);
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.SimplePage

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.