use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class JdbcTagDaoTest method tagsWithTopArtistsAreNotPickedForUpdate.
@Test
public void tagsWithTopArtistsAreNotPickedForUpdate() {
deleteTags();
List<String> tagNames = Arrays.asList("disco", "sludge");
dao.createTags(tagNames);
dao.setTopTags(tagNames);
List<TagTopArtists> topArtists = Arrays.asList(new TagTopArtists("disco", asList(new Artist("Madonna"))));
dao.createTopArtists(topArtists);
List<Tag> tags = dao.getTagsWithoutTopArtists();
Assert.assertEquals(1, tags.size());
Assert.assertEquals("sludge", tags.get(0).getName());
}
use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class JdbcArtistTopTagsDaoTest method storeUpdateAndValidateTopTags.
@Test
public void storeUpdateAndValidateTopTags() throws ApplicationException {
deleteArtistTopTags();
dao.createTopTags(cherArtist, cherTopTags);
dao.createTopTags(rihannaArtist, rihannaTopTags);
rihannaTopTags = new ArrayList<>();
rihannaTopTags.add(new Tag("dance", (short) 22));
rihannaTopTags.add(new Tag("r&b", (short) 8));
dao.createTopTags(rihannaArtist, rihannaTopTags);
List<Tag> cherStoredTopTags = dao.getTopTags(cherArtist.getId());
List<Tag> rihannaStoredTopTags = dao.getTopTags(rihannaArtist.getId());
assertEquals(100, cherStoredTopTags.size());
assertEquals(2, rihannaStoredTopTags.size());
for (int i = 0; i < cherTopTags.size(); i++) {
assertTrue(cherStoredTopTags.contains(cherTopTags.get(i)));
}
for (int i = 0; i < rihannaTopTags.size(); i++) {
assertTrue(rihannaStoredTopTags.contains(rihannaTopTags.get(i)));
}
}
use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class JdbcArtistTopTagsDaoTest method returnsMostPopularCloudTagsForArtist.
@Test
public void returnsMostPopularCloudTagsForArtist() throws ApplicationException {
deleteArtistTopTags();
dao.createTopTags(cherArtist, cherTopTags);
int cherId = musicDao.getArtistId(cherArtist);
Tag tagPop = new Tag("pop", (short) 100), tag80s = new Tag("80s", (short) 52);
tagDao.setTopTags(Arrays.asList(tagPop.getName(), tag80s.getName()));
assertEquals(asList(tagPop), dao.getTopTags(cherId, 1));
assertEquals(asList(tagPop, tag80s), dao.getTopTags(cherId, 3));
}
use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method importTagRelatedDataNotPossibleTwice.
@Test
public void importTagRelatedDataNotPossibleTwice() {
tagDao.createTags(Arrays.asList("disco"));
Tag tag = tagDao.getTags().get(0);
Calltype TOP_ARTISTS = Calltype.TAG_GET_TOP_ARTISTS;
WebserviceInvocation topArtists = new WebserviceInvocation(TOP_ARTISTS, tag);
deleteWebserviceInvocations();
assertTrue(dao.isWebserviceInvocationAllowed(topArtists));
dao.logWebserviceInvocation(topArtists);
assertFalse(dao.isWebserviceInvocationAllowed(topArtists));
}
use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class JdbcArtistTopTagsDao method batchInsert.
private void batchInsert(Artist artist, List<Tag> tags) {
int sourceArtistId = jdbcTemplate.queryForInt("select * from music.get_artist_id(?)", artist.getName());
String sql = "insert into music.artisttoptag_import (artist_id, tag_name, tag_count) values (?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("artist_id", Types.INTEGER));
batchUpdate.declareParameter(new SqlParameter("tag_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("tag_count", Types.SMALLINT));
for (Tag tag : tags) {
batchUpdate.update(new Object[] { sourceArtistId, tag.getName(), tag.getCount() });
}
batchUpdate.flush();
}
Aggregations