Package com.pugh.sockso.web.action.api

Source Code of com.pugh.sockso.web.action.api.ArtistTracksActionTest

package com.pugh.sockso.web.action.api;

import com.pugh.sockso.tests.SocksoTestCase;
import com.pugh.sockso.tests.TestDatabase;
import com.pugh.sockso.tests.TestResponse;

public class ArtistTracksActionTest extends SocksoTestCase {

    private ArtistTracksAction action;
   
    @Override
    protected void setUp() {
        action = new ArtistTracksAction();
    }
   
    public void testActionHandlesArtistTracksUrls() {
        assertTrue( action.canHandle(getRequest( "/api/artists/123/tracks" )) );
        assertTrue( action.canHandle(getRequest( "/api/artists/456/tracks/" )) );
        assertTrue( action.canHandle(getRequest( "/api/artists/456/tracks?index=foo" )) );
    }
   
    public void testActionDoesntHandleNonArtistTracksUrls() {
        assertFalse( action.canHandle(getRequest( "/api/artists/123" )) );
        assertFalse( action.canHandle(getRequest( "/api/albums/123/tracks" )) );
    }
   
    public void testTracksListedWhenArtistIdFound() throws Exception {
        TestDatabase db = new TestDatabase();
        TestResponse res = new TestResponse();
        db.fixture( "tracksForPath" );
        action.setDatabase( db );
        action.setResponse( res );
        action.setRequest(getRequest( "/api/artists/1/tracks" ));
        action.handleRequest();
        assertContains( res.getOutput(), "My Track 1" );
        assertContains( res.getOutput(), "My Track 2" );
        assertContains( res.getOutput(), "My Track 3" );
    }
   
}
TOP

Related Classes of com.pugh.sockso.web.action.api.ArtistTracksActionTest

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.