package com.github.felixgail.gplaymusic;

import com.github.felixgail.gplaymusic.model.Artist;
import com.github.felixgail.gplaymusic.util.TestUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import svarzee.gps.gpsoauth.Gpsoauth;

import java.io.IOException;

import static com.github.felixgail.gplaymusic.TestWithLogin.getApi;
import static com.github.felixgail.gplaymusic.TestWithLogin.loginToService;

public class ArtistTest {

  @BeforeClass
  public static void before() throws IOException, Gpsoauth.TokenRequestFailed {
    loginToService(TestUtil.USERNAME, TestUtil.PASSWORD, TestUtil.ANDROID_ID, TestUtil.TOKEN);
  }

  @Test
  public void testRelatedArtists() throws IOException {
    Artist artist = getApi().getArtist(TestUtil.get("test.artist").get(), false, 0, 10);
    Assert.assertNotNull(artist);
    Assert.assertTrue(artist.getRelatedArtists().isPresent());
    Assert.assertNotEquals(0, artist.getRelatedArtists().get().size());
  }


}

@@ -84,24 +84,154 @@
 del.Artist;%0A
+import com.github.felixgail.gplaymusic.model.enums.ResultType;%0Aimport com.github.felixgail.gplaymusic.model.requests.SearchTypes;%0A
 import com.g
@@ -272,16 +272,16 @@
 stUtil;%0A
-
 import o
@@ -416,16 +416,39 @@
 ception;
+%0Aimport java.util.List;
 %0A%0Aimport
@@ -880,21 +880,31 @@
     
+List%3C
 Artist
+%3E
  artist
+List
  = g
@@ -915,44 +915,325 @@
 i().
-getArtist(TestUtil.get(%22test.artist%22
+search(%22John%22, new SearchTypes(ResultType.ARTIST)).getArtists();%0A    Assert.assertNotNull(artistList);%0A    Assert.assertNotEquals(0, artistList.size());%0A    int relArtistNum = 0;%0A    for(Artist artist : artistList) %7B%0A      if(artist.getArtistId().isPresent()) %7B%0A        artist = getApi().getArtist(artist.getArtistId(
 ).ge
@@ -1252,16 +1252,20 @@
 0, 10);%0A
+    
     Asse
@@ -1298,25 +1298,14 @@
     
-Assert.assertTrue
+    if
 (art
@@ -1340,18 +1340,53 @@
 esent())
-;%0A
+%7B%0A          relArtistNum += 1;%0A      
     Asse
@@ -1449,16 +1449,295 @@
 ize());%0A
+        %7D%0A      %7D%0A    %7D%0A    Assert.assertNotEquals(%0A        String.format(%22No Artist (of %25d) had a list of related artists%22, artistList.size()), 0,%0A        relArtistNum);%0A    System.out.printf(%22%25d of %25d artists had a list of related artists%5Cn%22, relArtistNum, artistList.size());%0A
   %7D%0A%0A%0A%7D%0A

complete test