FileDocCategorySizeDatePackage
TestGDataUser.javaAPI DocApache Lucene 2.1.04685Wed Feb 14 10:46:02 GMT 2007org.apache.lucene.gdata.data

TestGDataUser

public class TestGDataUser extends TestCase
author
Simon Willnauer

Fields Summary
private GDataAccount
user
Constructors Summary
Methods Summary
protected voidsetUp()

        this.user = new GDataAccount();
        this.user.setName("simonW");
        super.setUp();
    
protected voidtearDown()

        
        super.tearDown();
    
public voidtestEquals()

        assertTrue(this.user.equals(this.user));
        GDataAccount a = new GDataAccount();
        a.setName(this.user.getName());
        assertTrue(this.user.equals(a));
        a.setName("someOtheraccount");
        assertFalse(this.user.equals(a));
        assertFalse(this.user.equals(null));
        assertFalse(this.user.equals(new String()));
        assertFalse(new GDataAccount().equals(new GDataAccount()));
    
public voidtestGetRolesAsInt()

        assertEquals(1,this.user.getRolesAsInt());
        this.user.setRole(AccountRole.ENTRYAMINISTRATOR);
        assertEquals(3,this.user.getRolesAsInt());
        this.user.setRole(AccountRole.FEEDAMINISTRATOR);
        assertEquals(7,this.user.getRolesAsInt());
        this.user.setRole(AccountRole.USERADMINISTRATOR);
        assertEquals(15,this.user.getRolesAsInt());
        
        
        
    
public voidtestHashCode()

        assertEquals(this.user.hashCode(),this.user.hashCode());
        assertFalse(this.user.hashCode()== this.user.getName().hashCode());
        GDataAccount a = new GDataAccount();
        a.setName(this.user.getName());
        assertEquals(this.user.hashCode(),a.hashCode());
        a.setName(null);
        assertFalse(a.hashCode()== this.user.hashCode());
    
public voidtestIsUserInRole()

        assertFalse(this.user.isUserInRole(null));
        assertTrue(this.user.isUserInRole(AccountRole.USER));
        assertFalse(this.user.isUserInRole(AccountRole.ENTRYAMINISTRATOR));
        this.user.setRole(AccountRole.ENTRYAMINISTRATOR);
        assertTrue(this.user.isUserInRole(AccountRole.ENTRYAMINISTRATOR));
    
public voidtestIsUserInRoleInt()

        assertFalse(GDataAccount.isInRole(1,AccountRole.ENTRYAMINISTRATOR));
        assertFalse(GDataAccount.isInRole(1,AccountRole.FEEDAMINISTRATOR));
        assertTrue(GDataAccount.isInRole(3,AccountRole.ENTRYAMINISTRATOR));
        assertTrue(GDataAccount.isInRole(15,AccountRole.ENTRYAMINISTRATOR));
        assertTrue(GDataAccount.isInRole(3,AccountRole.USER));
        assertTrue(GDataAccount.isInRole(15,AccountRole.USERADMINISTRATOR));
        assertFalse(GDataAccount.isInRole(7,AccountRole.USERADMINISTRATOR));
        assertFalse(GDataAccount.isInRole(7,null));
    
public voidtestReqValuesSet()

        assertFalse(this.user.requiredValuesSet());
        this.user.setPassword("hello");
        assertFalse(this.user.requiredValuesSet());
        this.user.setPassword("helloworld");
        assertTrue(this.user.requiredValuesSet());
        assertFalse(new GDataAccount().requiredValuesSet());
    
public voidtestSetRolesAsInt()

        this.user.setRolesAsInt(2);
        this.user.setRolesAsInt(4);
        this.user.setRolesAsInt(8);
        assertEquals(4,this.user.getRoles().size()); 
        this.user.setRolesAsInt(15);
        assertEquals(4,this.user.getRoles().size());
        this.user = new GDataAccount();
        this.user.setName("simon");
        this.user.setRolesAsInt(15);
        assertEquals(4,this.user.getRoles().size());
        
    
public voidtestToStringPrevNulPEx()

        assertNotNull(this.user.toString());