use of com.github.hakko.musiccabinet.domain.model.aggr.PlaylistItem in project musiccabinet by hakko.
the class PlaylistGeneratorServiceTest method noAdjacentArtistsInPlaylist.
@Test
public void noAdjacentArtistsInPlaylist() {
List<PlaylistItem> ts = new ArrayList<>();
ts.add(new PlaylistItem(1, 1));
ts.add(new PlaylistItem(1, 2));
ts.add(new PlaylistItem(1, 3));
ts.add(new PlaylistItem(2, 4));
ts.add(new PlaylistItem(2, 5));
ts.add(new PlaylistItem(2, 6));
ts.add(new PlaylistItem(3, 7));
ts.add(new PlaylistItem(3, 8));
ts.add(new PlaylistItem(3, 9));
ts.add(new PlaylistItem(4, 10));
ts.add(new PlaylistItem(4, 11));
ts.add(new PlaylistItem(4, 12));
ts.add(new PlaylistItem(5, 13));
ts.add(new PlaylistItem(5, 14));
ts.add(new PlaylistItem(5, 15));
ts.add(new PlaylistItem(6, 16));
ts.add(new PlaylistItem(6, 17));
ts.add(new PlaylistItem(6, 18));
ts.add(new PlaylistItem(7, 19));
ts.add(new PlaylistItem(7, 20));
ts.add(new PlaylistItem(7, 21));
ts.add(new PlaylistItem(8, 22));
ts.add(new PlaylistItem(8, 23));
ts.add(new PlaylistItem(8, 24));
Random rnd = new Random(1258114665843L);
for (int i = 0; i < 1000; i++) {
Collections.shuffle(ts, rnd);
playlistGeneratorService.distributeArtists(ts);
for (int j = 1; j < ts.size(); j++) {
if (ts.get(j).getArtistId() == ts.get(j - 1).getArtistId()) {
Assert.fail("Found adjacent artists in list!");
}
}
}
}
use of com.github.hakko.musiccabinet.domain.model.aggr.PlaylistItem 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());
}
Aggregations