Package com.dodo.blog.ui.util

Source Code of com.dodo.blog.ui.util.UriConstructorTest

package com.dodo.blog.ui.util;

import com.dodo.blog.model.Article;
import com.dodo.blog.model.Category;
import com.dodo.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;

import java.util.Random;

/**
* @author <a href="mailto:pohorelec@comvai.com">Jozef Pohorelec</a>
*/
public class UriConstructorTest
{
    @Test
    public void testCreateArticleUri() throws Exception
    {
        Assert.assertEquals( "", UriConstructor.createArticleUri( null ) );

        Article article = new Article();
        Assert.assertEquals( "", UriConstructor.createArticleUri( article ) );

        article = new Article();
        article.setId( 12345L );
        article.setTitle( "Google App engine" );
        Assert.assertEquals( "/articles/id/12345/google-app-engine", UriConstructor.createArticleUri( article ) );
    }

    @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 ) );
    }

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

        Tag tag = new Tag();
        Assert.assertEquals( "", UriConstructor.createTagUri( tag ) );

        tag = new Tag();
        tag.setName( "HTML5" );
        Assert.assertEquals( "/articles/tag/html5", UriConstructor.createTagUri( tag ) );
    }

    @Test
    public void testCreateDateUri() throws Exception
    {
        Assert.assertEquals( "", UriConstructor.createDateUri( null, null, null ) );
        Assert.assertEquals( "/articles/date/2011", UriConstructor.createDateUri( "2011", null, null ) );
        Assert.assertEquals( "/articles/date/2011/11", UriConstructor.createDateUri( "2011", "11", null ) );
        Assert.assertEquals( "/articles/date/2011/11/22", UriConstructor.createDateUri( "2011", "11", "22" ) );
    }

    @Test
    public void test()
    {
        Random r = new Random();
        for ( int i = 0; i < 30; i++ )
        {
            System.out.println( r.nextInt( 14 ) + 10 );
        }
    }

}
TOP

Related Classes of com.dodo.blog.ui.util.UriConstructorTest

TOP
Copyright © 2018 www.massapi.com. 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.