Search in sources :

Example 21 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class TagInfoParserTest method resourceFileCorrectlyParsed.

@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
    TagInfoParser parser = new TagInfoParserImpl(new ResourceUtil(TAG_INFO_FILE).getInputStream());
    TagInfo tagInfo = parser.getTagInfo();
    Assert.assertEquals(NAME, tagInfo.getTagName());
    Assert.assertEquals(SUMMARY, tagInfo.getSummary());
    Assert.assertEquals(CONTENT, tagInfo.getContent());
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) TagInfo(com.github.hakko.musiccabinet.domain.model.music.TagInfo) Test(org.junit.Test)

Example 22 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class ArtistQueryParserTest method emptyResourceFileCorrectlyParsed.

@Test
public void emptyResourceFileCorrectlyParsed() throws ApplicationException {
    ArtistQueryParser parser = new ArtistQueryParserImpl(new ResourceUtil(ARTIST_QUERY_EMPTY_FILE).getInputStream());
    MBArtist artist = parser.getArtist();
    assertNull(artist);
}
Also used : MBArtist(com.github.hakko.musiccabinet.domain.model.music.MBArtist) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Test(org.junit.Test)

Example 23 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class ArtistQueryParserTest method resourceFileCorrectlyParsed.

@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
    ArtistQueryParser parser = new ArtistQueryParserImpl(new ResourceUtil(ARTIST_QUERY_FILE).getInputStream());
    MBArtist artist = parser.getArtist();
    assertEquals(MBID, artist.getMbid());
    assertEquals(NAME, artist.getName());
    assertEquals(COUNTRY_CODE, artist.getCountryCode());
    assertEquals(START_YEAR, artist.getStartYear());
    assertEquals(ACTIVE, artist.isActive());
}
Also used : MBArtist(com.github.hakko.musiccabinet.domain.model.music.MBArtist) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Test(org.junit.Test)

Example 24 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class ArtistQueryParserTest method dateGetsStoredAsYearOnly.

@Test
public void dateGetsStoredAsYearOnly() throws ApplicationException {
    ArtistQueryParser parser = new ArtistQueryParserImpl(new ResourceUtil(ARTIST_QUERY_DATE_FILE).getInputStream());
    MBArtist artist = parser.getArtist();
    assertEquals(YEAR_PART, artist.getStartYear());
}
Also used : MBArtist(com.github.hakko.musiccabinet.domain.model.music.MBArtist) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Test(org.junit.Test)

Example 25 with ResourceUtil

use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.

the class DatabaseAdministrationService method getDatabaseUpdates.

/*
     * Load the list of database updates, defined in properties file.
     * An "update" is an integer number, that maps to a file consisting DDL statements.
     * Updates are always run chronologically, as one update may depend on (or alter) a
     * previous one (relying on a schema, adding/removing a column of a table etc).
     */
protected List<Integer> getDatabaseUpdates() {
    List<Integer> updates = new ArrayList<>();
    Properties props = new Properties();
    try (ResourceUtil resourceUtil = new ResourceUtil(VERSION_PROPERTIES)) {
        props.load(resourceUtil.getInputStream());
    } catch (IOException e) {
        LOG.warn("Could not load database updates list!", e);
    }
    for (Object key : props.keySet()) {
        updates.add(toInt(key.toString()));
    }
    Collections.sort(updates);
    return updates;
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Properties(java.util.Properties)

Aggregations

ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)45 Test (org.junit.Test)25 Before (org.junit.Before)7 HttpClient (org.apache.http.client.HttpClient)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 Track (com.github.hakko.musiccabinet.domain.model.music.Track)5 ResponseHandler (org.apache.http.client.ResponseHandler)5 File (com.github.hakko.musiccabinet.domain.model.library.File)4 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)4 ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)4 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)4 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)4 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)4 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)3 MBArtist (com.github.hakko.musiccabinet.domain.model.music.MBArtist)3 ArtistTopTracksParserImpl (com.github.hakko.musiccabinet.parser.lastfm.ArtistTopTracksParserImpl)3 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)3 ArrayList (java.util.ArrayList)3 UserLovedTracks (com.github.hakko.musiccabinet.domain.model.aggr.UserLovedTracks)2 UserStarredTrack (com.github.hakko.musiccabinet.domain.model.aggr.UserStarredTrack)2