Package org.jtalks.jcommune.model.entity

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


            ModelAndView modelAndView) throws Exception {
        super.postHandle(request, response, handler, modelAndView);
        if (modelAndView != null) {
            Map<String, Banner> allBanersOfTheForum = bannerService.getAllBanners();
            modelAndView.addObject("banners", allBanersOfTheForum);
            modelAndView.addObject("uploadedBanner", new Banner());
        }
    }
View Full Code Here


    @Test
    public void afterBannerUploadingUserShouldStayInTheSamePage() {
        HttpServletRequest request = mock(HttpServletRequest.class);
        String initialPage = "/topics/2";
        when(request.getHeader("referer")).thenReturn(initialPage);
        Banner uploadedBanner = new Banner();
       
        String resultUrl = bannerController.upload(uploadedBanner, request);
       
        assertEquals(resultUrl, "redirect:" + initialPage);
    }
View Full Code Here

        bannerService = new TransactionalBannerService(bannerDao);
    }
   
    @Test
    public void newBannerShouldBeSaved() {
        Banner uploadedBanner = new Banner(BannerPosition.TOP, "<html></html>");
        bannerService.uploadBanner(uploadedBanner, new Component());

        verify(bannerDao).saveOrUpdate(uploadedBanner);
    }
View Full Code Here

        verify(bannerDao).saveOrUpdate(uploadedBanner);
    }

    @Test
    public void existingBannerShouldBeSavedWithNewContent() {
        Banner newBanner = new Banner(BannerPosition.TOP, "<html></html>");
        Banner existingBanner = new Banner(BannerPosition.TOP, "<html>exists banner</html>");
        when(bannerDao.getByPosition(BannerPosition.TOP)).thenReturn(existingBanner);

        bannerService.uploadBanner(newBanner, new Component());

        verify(bannerDao).saveOrUpdate(existingBanner);
        assertEquals(existingBanner.getContent(), newBanner.getContent(), "Content of banner must be changed.");
    }
View Full Code Here

        assertEquals(existingBanner.getContent(), newBanner.getContent(), "Content of banner must be changed.");
    }

    @Test
    public void bannersShouldBeFoundFromRepository() {
        Banner topBanner = new Banner(BannerPosition.TOP, "TOP");
        Banner bottomBanner = new Banner(BannerPosition.BOTTOM, "BOTTOM");
        List<Banner> banners = Arrays.asList(topBanner, bottomBanner);
        when(bannerDao.getAll()).thenReturn(banners);

        Map<String, Banner> positionToBannerMap = bannerService.getAllBanners();
View Full Code Here

     *                       component and thus is allowed to upload banners
     */
    @Override
    @PreAuthorize("hasPermission(#forumComponent.id, 'COMPONENT', 'GeneralPermission.ADMIN')")
    public void uploadBanner(Banner uploadedBanner, Component forumComponent) {
        Banner existBanner = getDao().getByPosition(uploadedBanner.getPositionOnPage());
        if (existBanner == null) {
            existBanner = uploadedBanner;
        } else {
            existBanner.setContent(uploadedBanner.getContent());
        }
        getDao().saveOrUpdate(existBanner);
    }
View Full Code Here

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

    @Test
    public void correctBannerShouldBeSaved() {
        Banner banner = ObjectsFactory.getDefaultBanner();

        bannerDao.saveOrUpdate(banner);

        assertNotSame(banner.getId(), 0, "Id not created");

        session.evict(banner);
        Banner bannerInDatabase = (Banner) session.get(Banner.class, banner.getId());

        assertReflectionEquals(banner, bannerInDatabase);
    }
View Full Code Here

        assertReflectionEquals(banner, bannerInDatabase);
    }

    @Test(expectedExceptions = {Exception.class})
    public void bannerWithNullContentShoulNotBeSaved() {
        Banner banner = ObjectsFactory.getDefaultBanner();
        banner.setContent(null);

        bannerDao.saveOrUpdate(banner);
    }
View Full Code Here

    }

    @Test
    public void correctBannerShouldBeUpdated() {
        String newContent = "<html><h1>New Header</h1><html>";
        Banner banner = ObjectsFactory.getDefaultBanner();
        session.save(banner);
        banner.setContent(newContent);
        //
        bannerDao.saveOrUpdate(banner);
        session.flush();
        session.evict(banner);
        Banner result = (Banner) session.get(Banner.class, banner.getId());

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

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

    @Test(expectedExceptions = org.hibernate.exception.ConstraintViolationException.class)
    public void bannerWithNullContentShouldNotBeUpdated() {
        Banner banner = ObjectsFactory.getDefaultBanner();
        session.save(banner);
        banner.setContent(null);

        bannerDao.saveOrUpdate(banner);
        session.flush();
    }
View Full Code Here

TOP

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

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.