package com.gabrielavara.choiceplayer.beatport;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.List;
import java.util.Optional;

import org.junit.Test;

import com.gabrielavara.choiceplayer.dto.Mp3;

public class BeatportSearcherTest {

    @Test
    public void testSearch() {
        // given
        Mp3 mp3 = new Mp3();
        mp3.setAlbum("Another Chance");
        mp3.setArtist("Above & Beyond pres. Oceanlab");

        // when
        Optional<BeatportAlbum> album = BeatportSearcher.search(mp3);

        // then
        assertTrue(album.isPresent());
        assertEquals(getExpectedAlbum(), album.get());
    }

    private BeatportAlbum getExpectedAlbum() {
        BeatportAlbum expected = new BeatportAlbum();
        expected.setTitle("Another Chance");
        List<String> expectedArtists = asList("OceanLab", "Above & Beyond");
        expected.setArtists(expectedArtists);
        BeatportTrack track1 = new BeatportTrack("1", expectedArtists, "Another Chance", "Original Mix");
        BeatportTrack track2 = new BeatportTrack("2", expectedArtists, "Another Chance", "Above & Beyond Club Mix");
        BeatportTrack track3 = new BeatportTrack("3", expectedArtists, "Another Chance", "Above & Beyond Club Edit");
        expected.setTracks(asList(track1, track2, track3));
        return expected;
    }

}
@@ -328,17 +328,16 @@
 rTest %7B%0A
-%0A
     @Tes
@@ -438,29 +438,26 @@
 Album(%22A
-nother Chance
+mun / Meta
 %22);%0A    
@@ -479,37 +479,35 @@
 st(%22
-Above & Beyond pres. Oceanlab
+Ilan Bluestone & Jason Ross
 %22);%0A
@@ -840,29 +840,26 @@
 Title(%22A
-nother Chance
+mun / Meta
 %22);%0A    
@@ -905,34 +905,36 @@
 st(%22
-OceanLab%22, %22Above & Beyond
+Ilan Bluestone%22, %22Jason Ross
 %22);%0A
@@ -1048,37 +1048,27 @@
 dArtists, %22A
-nother Chance
+mun
 %22, %22Original
@@ -1151,167 +1151,28 @@
 s, %22
-Another Chance%22, %22Above & Beyond Club Mix%22);%0A        BeatportTrack track3 = new BeatportTrack(%223%22, expectedArtists, %22Another Chance%22, %22Above & Beyond Club Edit
+Meta%22, %22Original Mix
 %22);%0A
@@ -1223,16 +1223,8 @@
 ack2
-, track3
 ));%0A

Fix BeatportSearcherTest