Search in sources :

Example 16 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class ArtistInfoParserTest method emptyFileReturnsEmptyInfo.

@Test
public void emptyFileReturnsEmptyInfo() throws ApplicationException {
    ArtistInfoParser parser = new ArtistInfoParserImpl(new ResourceUtil(EMPTY_ARTIST_INFO_FILE).getInputStream());
    ArtistInfo artistInfo = parser.getArtistInfo();
    Assert.assertNull(artistInfo);
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Example 17 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class ArtistSimilarityParserTest method resourceFileCorrectlyParsed.

@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
    ArtistSimilarityParser parser = new ArtistSimilarityParserImpl(new ResourceUtil(ARTIST_SIMILARITY_FILE).getInputStream());
    assertNotNull(parser.getArtist());
    assertNotNull(parser.getArtistRelations());
    assertTrue(parser.getArtist().getName().equals("Cher"));
    assertEquals(parser.getArtistRelations().size(), 100);
    for (ArtistRelation ar : parser.getArtistRelations()) {
        assertNotNull(ar.getTarget());
    }
    verifyArtistRelation(parser, 0, "Sonny & Cher", 1.0f);
    verifyArtistRelation(parser, 1, "Madonna", 0.476751f);
    verifyArtistRelation(parser, 2, "Cyndi Lauper", 0.407297f);
    verifyArtistRelation(parser, 99, "Lara Fabian", 0.0617754f);
}
Also used : ArtistRelation(com.github.hakko.musiccabinet.domain.model.music.ArtistRelation) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Test(org.junit.Test)

Example 18 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class ArtistTopTagsParserTest method resourceFileCorrectlyParsed.

@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
    ArtistTopTagsParser parser = new ArtistTopTagsParserImpl(new ResourceUtil(TOP_TAGS_FILE).getInputStream());
    assertNotNull(parser.getArtist());
    assertNotNull(parser.getTopTags());
    assertTrue(parser.getArtist().getName().equals("Cher"));
    assertEquals(parser.getTopTags().size(), 100);
    for (Tag tag : parser.getTopTags()) {
        assertNotNull(tag);
        assertNotNull(tag.getName());
    }
    verifyTopTag(parser, 0, "pop", 100);
    verifyTopTag(parser, 1, "female vocalists", 72);
    verifyTopTag(parser, 98, "women", 0);
    verifyTopTag(parser, 99, "techno", 0);
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) Test(org.junit.Test)

Example 19 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class ArtistTopTracksParserTest method resourceFileCorrectlyParsed.

@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
    ArtistTopTracksParser parser = new ArtistTopTracksParserImpl(new ResourceUtil(TOP_TRACK_FILE).getInputStream());
    assertNotNull(parser.getArtist());
    assertNotNull(parser.getTopTracks());
    assertTrue(parser.getArtist().getName().equals("Cher"));
    assertEquals(parser.getTopTracks().size(), 50);
    for (Track track : parser.getTopTracks()) {
        assertNotNull(track);
        assertNotNull(track.getArtist());
        assertEquals(track.getArtist(), parser.getArtist());
    }
    verifyTopTrack(parser, 0, "Believe");
    verifyTopTrack(parser, 1, "If I Could Turn Back Time");
    verifyTopTrack(parser, 2, "Welcome To Burlesque");
    verifyTopTrack(parser, 49, "Gypsys, Tramps and Thieves");
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Test(org.junit.Test)

Example 20 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class ScrobbledTracksParserTest method resourceFileCorrectlyParsed.

@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
    ScrobbledTracksParser parser = new ScrobbledTracksParserImpl(new ResourceUtil(LIBRARY_TRACKS_FILE).getInputStream());
    assertNotNull(parser.getTrackPlayCounts());
    assertEquals(parser.getPage(), (short) 1);
    assertEquals(parser.getTotalPages(), (short) 151);
    assertEquals(parser.getTrackPlayCounts().size(), 100);
    for (TrackPlayCount trackPlayCount : parser.getTrackPlayCounts()) {
        assertNotNull(trackPlayCount.getTrack());
        assertNotNull(trackPlayCount.getTrack().getArtist());
    }
    verifyLibraryTrack(parser, 0, "Can", "Thief", 181);
    verifyLibraryTrack(parser, 1, "Roffe Ruff", "Ormar i gräset", 144);
    verifyLibraryTrack(parser, 2, "Dungen", "Du E för Fin för Mig", 143);
    verifyLibraryTrack(parser, 99, "The Radio Dept.", "Gibraltar", 41);
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) TrackPlayCount(com.github.hakko.musiccabinet.domain.model.library.TrackPlayCount) Test(org.junit.Test)

Aggregations

ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)45 Test (org.junit.Test)25 Before (org.junit.Before)7 HttpClient (org.apache.http.client.HttpClient)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 Track (com.github.hakko.musiccabinet.domain.model.music.Track)5 ResponseHandler (org.apache.http.client.ResponseHandler)5 File (com.github.hakko.musiccabinet.domain.model.library.File)4 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)4 ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)4 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)4 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)4 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)4 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)3 MBArtist (com.github.hakko.musiccabinet.domain.model.music.MBArtist)3 ArtistTopTracksParserImpl (com.github.hakko.musiccabinet.parser.lastfm.ArtistTopTracksParserImpl)3 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)3 ArrayList (java.util.ArrayList)3 UserLovedTracks (com.github.hakko.musiccabinet.domain.model.aggr.UserLovedTracks)2 UserStarredTrack (com.github.hakko.musiccabinet.domain.model.aggr.UserStarredTrack)2