Package com.dodo.blog.server.impl.it

Source Code of com.dodo.blog.server.impl.it.TagServiceTest

package com.dodo.blog.server.impl.it;

import com.dodo.blog.model.Tag;
import com.dodo.blog.request.BasicRequest;
import com.dodo.blog.server.TagService;
import com.google.guiceberry.junit4.GuiceBerryRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

import javax.inject.Inject;
import java.util.List;

/**
* @author <a href="mailto:pohorelec@comvai.com">Jozef Pohorelec</a>
*/
public class TagServiceTest
        extends ServicesEnvironment
{
    @Rule
    public final GuiceBerryRule guiceBerry = new GuiceBerryRule( ServicesEnvironment.class );

    @Inject
    private TagService tagService;

    @Test
    public void testSaveTag()
    {
        Assert.assertNotNull( saveTag().getId() );
    }

    @Test
    public void testGetTagByNormalizedName()
    {
        Tag tag = saveTag();
        tag = tagService.getTagById( tag.getId() );

        Assert.assertEquals( "google-app-engine", tag.getNormalizedName() );
    }

    @Test
    public void testDeleteTag()
    {
        Tag tag = saveTag();

        Long id = tag.getId();
        tagService.deleteTag( id );
        Assert.assertNull( tagService.getTagById( id ) );
    }

    @Test
    public void testGetTagList()
    {
        saveTag();

        List<Tag> tags = tagService.getTagList( new BasicRequest( 0, 20 ) );
        Assert.assertEquals( 1, tags.size() );
        Assert.assertEquals( "Google App Engine", tags.get( 0 ).getName() );
    }

    private Tag saveTag()
    {
        Tag tag = new Tag();
        tag.setName( "Google App Engine" );
        tagService.saveTag( tag );

        return tag;
    }
}
TOP

Related Classes of com.dodo.blog.server.impl.it.TagServiceTest

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.