Package com.dodo.blog.model

Examples of com.dodo.blog.model.Article


    }

    @Test
    public void testPublish() throws Exception
    {
        Article article = saveArticle();

        // test after publish
        articleService.publishArticle( article.getId() );

        article = articleService.getArticleById( article.getId() );
        Assert.assertTrue( article.isPublished() );
        Assert.assertTrue( article.getPublishedDate().after( article.getCreatedDate() ) );
    }
View Full Code Here


    }

    @Test
    public void testHide() throws Exception
    {
        Article article = saveArticle();

        // test after hide
        articleService.hideArticle( article.getId() );

        article = articleService.getArticleById( article.getId() );
        Assert.assertFalse( article.isPublished() );
        Assert.assertNull( article.getPublishedDate() );
    }
View Full Code Here

        Assert.assertNull( article.getPublishedDate() );
    }

    private Article saveArticle()
    {
        Article article = new Article();
        article.setTitle( "True about GAE" );
        articleService.saveArticle( article );

        return article;
    }
View Full Code Here

    }

    @Test
    public void testGetArticleById() throws Exception
    {
        Article article = saveArticle();
        article = articleService.getArticleById( article.getId() );

        Assert.assertEquals( "True about GAE", article.getTitle() );
    }
View Full Code Here

    @Test
    public void testGetArticlesByCategory() throws Exception
    {
        Category category = saveCategory();

        Article article = new Article();
        article.setCategory( category.getId() );
        articleService.saveArticle( article );

        ArticlesRequest request = new ArticlesRequest( -1, -1 );
        request.setCategory( "backend" );
        List<Article> articles = articleService.getArticles( request );
View Full Code Here

    {
        Tag tag = saveTag();

        for ( int i = 0; i < 30; i++ )
        {
            Article article = new Article();
            article.setTag_1( tag.getId() );
            articleService.saveArticle( article );

            article = new Article();
            article.setTag_2( tag.getId() );
            articleService.saveArticle( article );
        }

        ArticlesRequest request = new ArticlesRequest( -1, 20 );
        request.setTag( "google-app-engine" );
View Full Code Here

    }

    @Test
    public void testGetArticlesByDate() throws Exception
    {
        Article article = new Article();
        articleService.saveArticle( article );

        Calendar calendar = Calendar.getInstance();
        calendar.setTime( new Date() );
        Format format = new DecimalFormat( "00" );
View Full Code Here

    }

    @Test
    public void testGetMostViewedArticles() throws Exception
    {
        Article article = new Article();
        article.setTitle( "0 views" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        article = new Article();
        article.incrementViewed();
        article.setTitle( "1 views" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        article = new Article();
        article.incrementViewed();
        article.incrementViewed();
        article.setTitle( "2 views" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        List<Article> articles = articleService.getMostViewedArticles();
        Assert.assertEquals( "2 views", articles.get( 0 ).getTitle() );
        Assert.assertEquals( "1 views", articles.get( 1 ).getTitle() );
        Assert.assertEquals( "0 views", articles.get( 2 ).getTitle() );
View Full Code Here

    }

    @Test
    public void testGetBestRatedArticles() throws Exception
    {
        Article article = new Article();
        article.setTitle( "0 rates" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        article = new Article();
        article.incrementRate( 3L );
        article.setTitle( "1 rates" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        article = new Article();
        article.incrementRate( 5l );
        article.setTitle( "2 rates" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        List<Article> articles = articleService.getBestRatedArticles();
        Assert.assertEquals( "2 rates", articles.get( 0 ).getTitle() );
        Assert.assertEquals( "1 rates", articles.get( 1 ).getTitle() );
        Assert.assertEquals( "0 rates", articles.get( 2 ).getTitle() );
View Full Code Here

    }

    @Test
    public void testGetRecentArticles() throws Exception
    {
        Article article = new Article();
        article.setTitle( "New" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        article = new Article();
        article.setTitle( "Newer" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        article = new Article();
        article.setTitle( "Newest" );
        articleService.saveArticle( article );
        articleService.publishArticle( article.getId() );

        List<Article> articles = articleService.getRecentArticles();
        Assert.assertEquals( "Newest", articles.get( 0 ).getTitle() );
        Assert.assertEquals( "Newer", articles.get( 1 ).getTitle() );
        Assert.assertEquals( "New", articles.get( 2 ).getTitle() );
View Full Code Here

TOP

Related Classes of com.dodo.blog.model.Article

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.