Package com.pugh.sockso.web

Examples of com.pugh.sockso.web.User


        db = new TestDatabase();
        cmd = new UserList( db );
    }

    public void testListingUsersReturnsTheirDetails() throws Exception {
        User user = new User( "foo", "", "foo@bar.com", true );
        user.save( db );
        String result = cmd.execute( new String[] { "userlist" } );
        assertContains( result, String.valueOf(user.getId()) );
        assertContains( result, user.getName() );
        assertContains( result, user.getEmail() );
    }
View Full Code Here


        assertContains( result, user.getName() );
        assertContains( result, user.getEmail() );
    }

    public void testActiveUsersAreNotListedAsPending() throws Exception {
        User user = new User( "foo", "", "foo@bar.com", true );
        user.save( db );
        String result = cmd.execute( new String[] { "userlist" } );
        assertNotContains( result, "PENDING" );
    }
View Full Code Here

        String result = cmd.execute( new String[] { "userlist" } );
        assertNotContains( result, "PENDING" );
    }

    public void testInactiveUsersAreListedAsPending() throws Exception {
        User user = new User( "foo", "", "foo@bar.com", true );
        user.setActive( false );
        user.save( db );
        String result = cmd.execute( new String[] { "userlist" } );
        assertContains( result, "PENDING" );
    }
View Full Code Here

        String result = cmd.execute( new String[] { "userlist" } );
        assertContains( result, "PENDING" );
    }

    public void testListingUsersIncludesAdminIfTheyAreAnAdmin() throws Exception {
        User user = new User( "foo", "", "foo@bar.com", true );
        user.save( db );
        assertContains( cmd.execute( new String[] { "userlist" } ), "ADMIN" );
    }
View Full Code Here

        user.save( db );
        assertContains( cmd.execute( new String[] { "userlist" } ), "ADMIN" );
    }

    public void testListingUsersDoesntIncludeAdminIfTheyAreNotAnAdmin() throws Exception {
        User user = new User( "foo", "", "foo@bar.com", false );
        user.save( db );
        assertNotContains( cmd.execute( new String[] { "userlist" } ), "ADMIN" );
    }
View Full Code Here

        assertTrue( !render().contains("recentUsers") );

        final Renderer r1 = getTemplate();
        assertTrue( !r1.asString().contains("recentUsers") );

        users.add( new User(1,"foo useR") );
        users.add( new User(1,"bar User") );
        final IFooter tpl1 = new IFooter();
        tpl1.setProperties( p );
        tpl1.setLocale( new TestLocale() );
        tpl1.setRecentUsers( users );
        final String html = tpl1.makeRenderer().asString();
View Full Code Here

           
            final List<Playlist> userPlaylists = new ArrayList<Playlist>();
            while ( rs.next() )
                userPlaylists.add( new Playlist(
                    rs.getInt("id"), rs.getString("name"), rs.getInt("trackCount"),
                    new User( rs.getInt("userId"), rs.getString("userName") )
                ));

            return userPlaylists;
           
        }
View Full Code Here

       
    }
   
    public void testLogTrackPlayedWithUser() throws SQLException {
       
        final User user = new User( 1, "foo" );
       
        final int trackId = 123;
       
        Track.Builder builder = new Track.Builder();
        builder.artist(null)
                .album(null)
                .genre(null)
                .id(trackId)
                .name("")
                .number(1)
                .path("")
                .dateAdded(null);
        final Track track = builder.build();
       
        final PreparedStatement st = createMock( PreparedStatement.class );
        st.setInt( 1, trackId );
        st.setInt( 2, user.getId() );
        expect( st.execute() ).andReturn( true );
        st.close();
        replay( st );
       
        final Database db = createMock( Database.class );
View Full Code Here

    public void testAdminActionRequiresLogin() {
        assertTrue( action.requiresLogin() );
    }

    public void testHandleRequestThrowsBadRequestExceptionWhenCurrentUserIsNotAdmin() {
        action.setUser(new User( 1, "foo", "foo@bar.com", false ));
        try {
            action.handleRequest();
            fail( "Expected exception to be thrown when user is not an admin" );
        }
        catch ( final Exception e ) {}
View Full Code Here

        }
        catch ( final Exception e ) {}
    }

    public void testHandleAdminRequestCalledWhenCurrentUserIsAnAdmin() throws Exception {
        action.setUser(new User( 1, "foo", "foo@bar.com", true ));
        action.handleRequest();
        assertTrue( action.requestHandled );
    }
View Full Code Here

TOP

Related Classes of com.pugh.sockso.web.User

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.