|
| 1 | +package com.github.felixgail.gplaymusic; |
| 2 | + |
| 3 | +import com.github.felixgail.gplaymusic.model.Artist; |
| 4 | +import com.github.felixgail.gplaymusic.model.enums.ResultType; |
| 5 | +import com.github.felixgail.gplaymusic.model.requests.SearchTypes; |
| 6 | +import com.github.felixgail.gplaymusic.util.TestUtil; |
| 7 | +import org.junit.Assert; |
| 8 | +import org.junit.BeforeClass; |
| 9 | +import org.junit.Test; |
| 10 | +import svarzee.gps.gpsoauth.Gpsoauth; |
| 11 | + |
| 12 | +import java.io.IOException; |
| 13 | +import java.util.List; |
| 14 | + |
| 15 | +import static com.github.felixgail.gplaymusic.TestWithLogin.getApi; |
| 16 | +import static com.github.felixgail.gplaymusic.TestWithLogin.loginToService; |
| 17 | + |
| 18 | +public class ArtistTest { |
| 19 | + |
| 20 | + @BeforeClass |
| 21 | + public static void before() throws IOException, Gpsoauth.TokenRequestFailed { |
| 22 | + loginToService(TestUtil.USERNAME, TestUtil.PASSWORD, TestUtil.ANDROID_ID, TestUtil.TOKEN); |
| 23 | + } |
| 24 | + |
| 25 | + @Test |
| 26 | + public void testRelatedArtists() throws IOException { |
| 27 | + List<Artist> artistList = getApi().search("John", new SearchTypes(ResultType.ARTIST)).getArtists(); |
| 28 | + Assert.assertNotNull(artistList); |
| 29 | + Assert.assertNotEquals(0, artistList.size()); |
| 30 | + int relArtistNum = 0; |
| 31 | + for(Artist artist : artistList) { |
| 32 | + if(artist.getArtistId().isPresent()) { |
| 33 | + artist = getApi().getArtist(artist.getArtistId().get(), false, 0, 10); |
| 34 | + Assert.assertNotNull(artist); |
| 35 | + if(artist.getRelatedArtists().isPresent()){ |
| 36 | + relArtistNum += 1; |
| 37 | + Assert.assertNotEquals(0, artist.getRelatedArtists().get().size()); |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | + Assert.assertNotEquals( |
| 42 | + String.format("No Artist (of %d) had a list of related artists", artistList.size()), 0, |
| 43 | + relArtistNum); |
| 44 | + System.out.printf("%d of %d artists had a list of related artists\n", relArtistNum, artistList.size()); |
| 45 | + } |
| 46 | + |
| 47 | + |
| 48 | +} |
0 commit comments