Search in sources :

Example 1 with TrackSimilarityParser

use of com.github.hakko.musiccabinet.parser.lastfm.TrackSimilarityParser in project musiccabinet by hakko.

the class JdbcPlaylistGeneratorDaoTest method addCherSimilarTracksAndGetPlaylist.

@Test
public void addCherSimilarTracksAndGetPlaylist() throws ApplicationException {
    TrackSimilarityParser tsParser = new TrackSimilarityParserImpl(new ResourceUtil(CHER_SIMILAR_TRACKS).getInputStream());
    trackRelationDao.createTrackRelations(tsParser.getTrack(), tsParser.getTrackRelations());
    List<File> files = new ArrayList<>();
    for (TrackRelation tr : tsParser.getTrackRelations()) {
        String artistName = tr.getTarget().getArtist().getName();
        if ("Madonna".equals(artistName)) {
            files.add(getFile(artistName, null, tr.getTarget().getName()));
        }
    }
    UnittestLibraryUtil.submitFile(additionDao, files);
    int trackId = musicDao.getTrackId(tsParser.getTrack().getArtist().getName(), tsParser.getTrack().getName());
    playlistGeneratorDao.updateSearchIndex();
    List<PlaylistItem> ts = playlistGeneratorDao.getPlaylistForTrack(trackId);
    Assert.assertNotNull(ts);
    Assert.assertEquals(2, ts.size());
}
Also used : TrackSimilarityParserImpl(com.github.hakko.musiccabinet.parser.lastfm.TrackSimilarityParserImpl) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) TrackSimilarityParser(com.github.hakko.musiccabinet.parser.lastfm.TrackSimilarityParser) TrackRelation(com.github.hakko.musiccabinet.domain.model.music.TrackRelation) ArrayList(java.util.ArrayList) UnittestLibraryUtil.getFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile) File(com.github.hakko.musiccabinet.domain.model.library.File) PlaylistItem(com.github.hakko.musiccabinet.domain.model.aggr.PlaylistItem) Test(org.junit.Test)

Aggregations

PlaylistItem (com.github.hakko.musiccabinet.domain.model.aggr.PlaylistItem)1 File (com.github.hakko.musiccabinet.domain.model.library.File)1 TrackRelation (com.github.hakko.musiccabinet.domain.model.music.TrackRelation)1 TrackSimilarityParser (com.github.hakko.musiccabinet.parser.lastfm.TrackSimilarityParser)1 TrackSimilarityParserImpl (com.github.hakko.musiccabinet.parser.lastfm.TrackSimilarityParserImpl)1 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)1 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1