Search in sources :

Example 41 with ResourceUtil

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

the class JdbcDatabaseAdministrationDaoEnvironmentDependentTest method getPostgresPassword.

private String getPostgresPassword() {
    Properties props = new Properties();
    try (ResourceUtil resourceUtil = new ResourceUtil("local.jdbc.properties")) {
        props.load(resourceUtil.getInputStream());
    } catch (IOException e) {
        Assert.fail("IOException encountered while reading password!");
    }
    String password = props.getProperty("musiccabinet.jdbc.password");
    Assert.assertNotNull(password);
    return password;
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) IOException(java.io.IOException) Properties(java.util.Properties)

Example 42 with ResourceUtil

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

the class JdbcUserTopArtistsDaoTest method loadFunctionDependency.

@Before
public void loadFunctionDependency() throws ApplicationException {
    PostgreSQLUtil.loadFunction(dao, UPDATE_USER_TOP_ARTISTS);
    arnOverall = new UserTopArtists(arn, Period.OVERALL, new UserTopArtistsParserImpl(new ResourceUtil(ARN_OVERALL_FILE).getInputStream()).getArtists());
    arn6month = new UserTopArtists(arn, Period.SIX_MONTHS, new UserTopArtistsParserImpl(new ResourceUtil(ARN_6MONTH_FILE).getInputStream()).getArtists());
    sys3month = new UserTopArtists(sys, Period.THREE_MONTHS, new UserTopArtistsParserImpl(new ResourceUtil(SYS_3MONTH_FILE).getInputStream()).getArtists());
    createArtistMetaData();
}
Also used : UserTopArtistsParserImpl(com.github.hakko.musiccabinet.parser.lastfm.UserTopArtistsParserImpl) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) UserTopArtists(com.github.hakko.musiccabinet.domain.model.aggr.UserTopArtists) Before(org.junit.Before)

Example 43 with ResourceUtil

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

the class WSResponseTest method failedKeyResponseValidatesCorrectly.

@Test
public void failedKeyResponseValidatesCorrectly() throws ApplicationException, IOException {
    String failedResponse = new ResourceUtil(FAILED_KEY_RESOURCE).getContent();
    WSResponse response = new WSResponse(failedResponse);
    assertFalse(response.wasCallSuccessful());
    assertEquals(26, response.getErrorCode());
    assertEquals("Suspended API key", response.getErrorMessage());
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Test(org.junit.Test)

Example 44 with ResourceUtil

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

the class WSResponseTest method normalResponseValidatesCorrectly.

@Test
public void normalResponseValidatesCorrectly() throws ApplicationException, IOException {
    String normalResponse = new ResourceUtil(TOP_TRACKS_RESOURCE).getContent();
    WSResponse response = new WSResponse(normalResponse);
    assertTrue(response.wasCallSuccessful());
    assertEquals(normalResponse, response.getResponseBody());
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Test(org.junit.Test)

Example 45 with ResourceUtil

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

the class WSResponseTest method failedTrackResponseValidatesCorrectly.

@Test
public void failedTrackResponseValidatesCorrectly() throws ApplicationException, IOException {
    String failedResponse = new ResourceUtil(FAILED_TRACK_RESOURCE).getContent();
    WSResponse response = new WSResponse(failedResponse);
    assertFalse(response.wasCallSuccessful());
    assertEquals(6, response.getErrorCode());
    assertEquals("Track not found", response.getErrorMessage());
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) Test(org.junit.Test)

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