2018-10-14 15:19:09 +00:00
|
|
|
package fr.ensim.json;
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import fr.ensim.xml.deezer.data.Album;
|
2018-10-14 15:26:06 +00:00
|
|
|
import fr.ensim.xml.deezer.data.Track;
|
2018-10-14 15:19:09 +00:00
|
|
|
|
|
|
|
public class JSONSearchAlbumTracksTest {
|
|
|
|
|
|
|
|
private static final Logger LOG = Logger.getLogger(JSONSearchAlbumTest.class);
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test() throws Exception {
|
|
|
|
LOG.debug(">>testParse");
|
|
|
|
|
|
|
|
// Recuperation du flux a parser
|
|
|
|
//InputStream in = getClass().getResourceAsStream("../list-albums.json");
|
2018-10-14 15:26:06 +00:00
|
|
|
InputStream in = getClass().getClassLoader().getResourceAsStream("fr/ensim/json/47685332.json");
|
2018-10-14 15:19:09 +00:00
|
|
|
|
2018-10-14 15:26:06 +00:00
|
|
|
List<Track> trackList = new JSONSearchAlbumTracks().find(in);
|
|
|
|
|
|
|
|
assertEquals(13, trackList.size());
|
2018-10-14 15:19:09 +00:00
|
|
|
//First album
|
2018-10-14 15:26:06 +00:00
|
|
|
assertEquals("Gung Ho", trackList.get(0).getTitle());
|
|
|
|
assertEquals("http://cdn-preview-a.deezer.com/stream/c-abbf47cd151375ceee9a5d3835545268-4.mp3", trackList.get(0).getPreview());
|
2018-10-14 15:19:09 +00:00
|
|
|
|
|
|
|
//Second album
|
2018-10-14 15:26:06 +00:00
|
|
|
assertEquals("Fear Ya", trackList.get(1).getTitle());
|
|
|
|
assertEquals("http://cdn-preview-f.deezer.com/stream/c-f2ff0cdc8bd8e4764f59d36ccf996d7c-4.mp3", trackList.get(1).getPreview());
|
2018-10-14 15:19:09 +00:00
|
|
|
|
|
|
|
LOG.debug("<<testParse");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|