use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method tagHistoryAllowanceIsBasedOnId.
@Test
public void tagHistoryAllowanceIsBasedOnId() {
tagDao.createTags(Arrays.asList("disco", "sludge"));
Tag tag1 = tagDao.getTags().get(0);
Tag tag2 = tagDao.getTags().get(1);
Calltype TOP_ARTISTS = Calltype.TAG_GET_TOP_ARTISTS;
WebserviceInvocation topArtists1 = new WebserviceInvocation(TOP_ARTISTS, tag1);
WebserviceInvocation topArtists2 = new WebserviceInvocation(TOP_ARTISTS, tag2);
deleteWebserviceInvocations();
assertTrue(dao.isWebserviceInvocationAllowed(topArtists1));
assertTrue(dao.isWebserviceInvocationAllowed(topArtists2));
dao.logWebserviceInvocation(topArtists2);
assertTrue(dao.isWebserviceInvocationAllowed(topArtists1));
assertFalse(dao.isWebserviceInvocationAllowed(topArtists2));
dao.logWebserviceInvocation(topArtists2);
assertTrue(dao.isWebserviceInvocationAllowed(topArtists1));
assertFalse(dao.isWebserviceInvocationAllowed(topArtists2));
dao.logWebserviceInvocation(topArtists1);
assertFalse(dao.isWebserviceInvocationAllowed(topArtists1));
assertFalse(dao.isWebserviceInvocationAllowed(topArtists2));
}
use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class JdbcTagDaoTest method retrievesCorrectedAvailableTags.
@Test
public void retrievesCorrectedAvailableTags() {
deleteTags();
for (int i = 0; i < 5; i++) {
artistTopTagsDao.createTopTags(new Artist("artist" + i), Arrays.asList(new Tag("sludge", (short) 100), new Tag("drone", (short) 90), new Tag("e-l-e-c-t-r-o", (short) 50), new Tag("disco", (short) 10)));
}
Map<String, String> tagCorrections = new HashMap<>();
tagCorrections.put("e-l-e-c-t-r-o", "electro");
dao.createTagCorrections(tagCorrections);
dao.setTopTags(Arrays.asList("sludge"));
List<TagOccurrence> tags = dao.getAvailableTags();
Assert.assertEquals(3, tags.size());
Assert.assertEquals("drone", tags.get(0).getTag());
Assert.assertEquals("e-l-e-c-t-r-o", tags.get(1).getTag());
Assert.assertEquals("electro", tags.get(1).getCorrectedTag());
Assert.assertEquals("sludge", tags.get(2).getTag());
Assert.assertFalse(tags.get(0).isUse());
Assert.assertFalse(tags.get(1).isUse());
Assert.assertTrue(tags.get(2).isUse());
}
use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class JdbcLibraryBrowserDaoAggregationTest method filterArtistsByGenre.
@Test
public void filterArtistsByGenre() {
String artist = artistName1, indieArtist = "Indie Artist", jazzArtist = "Jazz Artist";
String indie = "indie", jazz = "jazz";
submitFile(additionDao, UnittestLibraryUtil.getFile(artist, "Album", "Title"));
submitFile(additionDao, UnittestLibraryUtil.getFile(indieArtist, "Album", "Title"));
submitFile(additionDao, UnittestLibraryUtil.getFile(jazzArtist, "Album", "Title"));
topTagsDao.createTopTags(new Artist(indieArtist), Arrays.asList(new Tag("indie", (short) 100)));
topTagsDao.createTopTags(new Artist(jazzArtist), Arrays.asList(new Tag("jazz", (short) 60)));
List<Artist> allArtists = browserDao.getArtists();
Assert.assertEquals(3, allArtists.size());
List<Artist> indieArtists = browserDao.getArtists(indie, 90);
Assert.assertEquals(1, indieArtists.size());
Assert.assertEquals(indieArtist, indieArtists.get(0).getName());
List<Artist> jazzArtists = browserDao.getArtists(jazz, 70);
Assert.assertEquals(0, jazzArtists.size());
}
use of com.github.hakko.musiccabinet.domain.model.music.Tag in project musiccabinet by hakko.
the class ArtistTopTagsParserTest method verifyTopTag.
private void verifyTopTag(ArtistTopTagsParser parser, int tagIndex, String tagName, int tagCount) {
Tag tag = parser.getTopTags().get(tagIndex);
assertTrue(tag.getName().equals(tagName));
assertEquals(tagCount, tag.getCount());
}
use of com.github.hakko.musiccabinet.domain.model.music.Tag 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);
}
Aggregations