Package com.dodo.blog.model

Examples of com.dodo.blog.model.Category


    @GetModel( name = CATEGORY_FORM )
    public Category getModel()
    {
        Long id = getLongParameter( CATEGORY_ID );

        Category category;
        if ( id != null )
        {
            category = categoryService.getCategoryById( id );
        }
        else
        {
            category = new Category();
        }

        return category;
    }
View Full Code Here


    @Test
    public void testCreateCategoriesUri() throws Exception
    {
        Assert.assertEquals( "", UriConstructor.createCategoyUri( null ) );

        Category category = new Category();
        Assert.assertEquals( "", UriConstructor.createCategoyUri( category ) );

        category = new Category();
        category.setName( "Frontend" );

        Assert.assertEquals( "/articles/category/frontend", UriConstructor.createCategoyUri( category ) );
    }
View Full Code Here

            Criteria<Article> criteria = Criteria.create( Article.class );
            processCriteria( criteria, request );

            if ( request.getCategory() != null )
            {
                Category category = categoryService.getCategoryByNormalizedName( request.getCategory() );

                // return empty result if category was not found
                if ( category == null )
                {
                    return new ArrayList<Article>();
                }

                criteria.addCriteria( Restrictions.eq( "category", category.getId() ) );
            }

            if ( request.isPublished() != null )
            {
                criteria.addCriteria( Restrictions.eq( "published", true ) );
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

        return tag;
    }

    private Category saveCategory()
    {
        Category category = new Category();
        category.setName( "Backend" );

        categoryService.saveCategory( category );

        return category;
    }
View Full Code Here

    }

    @Test
    public void testGetCategoryByNormalizedName()
    {
        Category category = saveCategory();
        category = categoryService.getCategoryById( category.getId() );

        Assert.assertEquals( "google-app-engine", category.getNormalizedName() );
    }
View Full Code Here

    }

    @Test
    public void testDeleteCategory()
    {
        Category category = saveCategory();

        Long id = category.getId();
        categoryService.deleteCategory( id );
        Assert.assertNull( categoryService.getCategoryById( id ) );
    }
View Full Code Here

        Assert.assertEquals( "Google App Engine", categoryList.get( 0 ).getName() );
    }

    private Category saveCategory()
    {
        Category category = new Category();
        category.setName( "Google App Engine" );
        categoryService.saveCategory( category );

        return category;
    }
View Full Code Here

TOP

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

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.