Search in sources :

Example 1 with Tag

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));
}
Also used : Calltype(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) Test(org.junit.Test)

Example 2 with Tag

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());
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) HashMap(java.util.HashMap) TagOccurrence(com.github.hakko.musiccabinet.domain.model.aggr.TagOccurrence) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) Test(org.junit.Test)

Example 3 with Tag

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());
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) Test(org.junit.Test)

Example 4 with Tag

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());
}
Also used : Tag(com.github.hakko.musiccabinet.domain.model.music.Tag)

Example 5 with Tag

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);
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) Test(org.junit.Test)

Aggregations

Tag (com.github.hakko.musiccabinet.domain.model.music.Tag)15 Test (org.junit.Test)11 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)4 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)3 TagTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.TagTopArtists)2 Calltype (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype)2 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)2 ArrayList (java.util.ArrayList)2 TagOccurrence (com.github.hakko.musiccabinet.domain.model.aggr.TagOccurrence)1 TagTopArtistsParser (com.github.hakko.musiccabinet.parser.lastfm.TagTopArtistsParser)1 TagTopArtistsParserImpl (com.github.hakko.musiccabinet.parser.lastfm.TagTopArtistsParserImpl)1 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)1 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)1 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)1 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)1 HashMap (java.util.HashMap)1 NameValuePair (org.apache.http.NameValuePair)1 SqlParameter (org.springframework.jdbc.core.SqlParameter)1 BatchSqlUpdate (org.springframework.jdbc.object.BatchSqlUpdate)1