Package com.dodo.blog.model

Examples of com.dodo.blog.model.Account


    }

    @Test
    public void testAuthenticateLoginAccount()
    {
        Account account = new Account();
        account.setLoginType( LoginType.LOGIN );
        account.setLogin( "dodo" );
        account.setPassword( "1111" );
        try
        {
            accountService.register( account );
        }
        catch ( Exception e )
        {
            Assert.fail( "This exception should not be thrown: " + e );
        }

        SessionUser sessionUser = new SessionUser();
        sessionUser.setLogin( account.getLogin() );
        sessionUser.setPassword( "1111" );
        sessionUser.setLoginType( LoginType.LOGIN );

        try
        {
            Account authorizedAccount = ( Account ) authService.authenticate( sessionUser );
            Assert.assertEquals( "dodo", authorizedAccount.getLogin() );
            Assert.assertEquals( "b59c67bf196a4758191e42f76670ceba", authorizedAccount.getPassword() );
        }
        catch ( AuthenticatedException e )
        {
            Assert.fail( "This exception should not be thrown: " + e );
        }
View Full Code Here


    }

    @Test
    public void testRate() throws Exception
    {
        Account account = new Account();
        accountService.saveAccount( account );

        // rate article
        Article article = saveArticle();
        article = articleService.rate( article.getId(), account.getId(), 5L );
        Assert.assertEquals( ( double ) 5, article.calculateRate() );

        // rate again to test exception
        try
        {
            articleService.rate( article.getId(), account.getId(), 3L );
            Assert.fail( UserAlreadyRated.class.getName() + " should be thrown." );
        }
        catch ( UserAlreadyRated e )
        {
            Assert.assertEquals( UserAlreadyRated.class, e.getClass() );
View Full Code Here

    }

    @Test
    public void testIsArticleRated() throws Exception
    {
        Account account = new Account();
        accountService.saveAccount( account );
        Article article = saveArticle();

        // test before rate
        Assert.assertFalse( articleService.isArticleRated( article.getId(), account.getId() ) );

        // test after rate
        articleService.rate( article.getId(), account.getId(), 5L );
        Assert.assertTrue( articleService.isArticleRated( article.getId(), account.getId() ) );
    }
View Full Code Here

TOP

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

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.