use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.
the class ArtistRelationServiceTest method getArtistSimilarityClient.
@SuppressWarnings("unchecked")
private ArtistSimilarityClient getArtistSimilarityClient(WebserviceHistoryService historyService) throws IOException {
// create a HTTP client that always returns Cher artist relations
HttpClient httpClient = mock(HttpClient.class);
ClientConnectionManager connectionManager = mock(ClientConnectionManager.class);
when(httpClient.getConnectionManager()).thenReturn(connectionManager);
String httpResponse = new ResourceUtil(CHER_ARTIST_RELATIONS).getContent();
when(httpClient.execute(Mockito.any(HttpUriRequest.class), Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);
// create a throttling service that allows calls at any rate
ThrottleService throttleService = mock(ThrottleService.class);
// create a client that allows all calls and returns Cher artist relations
ArtistSimilarityClient asClient = new ArtistSimilarityClient();
asClient.setWebserviceHistoryService(historyService);
asClient.setHttpClient(httpClient);
asClient.setThrottleService(throttleService);
return asClient;
}
use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.
the class ArtistTopTagsServiceTest method getArtistTopTagsClient.
@SuppressWarnings("unchecked")
private ArtistTopTagsClient getArtistTopTagsClient(WebserviceHistoryService historyService) throws IOException {
// create a HTTP client that always returns Cher top tracks
HttpClient httpClient = mock(HttpClient.class);
ClientConnectionManager connectionManager = mock(ClientConnectionManager.class);
when(httpClient.getConnectionManager()).thenReturn(connectionManager);
String httpResponse = new ResourceUtil(CHER_TOP_TAGS).getContent();
when(httpClient.execute(Mockito.any(HttpUriRequest.class), Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);
// create a throttling service that allows calls at any rate
ThrottleService throttleService = mock(ThrottleService.class);
// create a client based on mocked HTTP client
ArtistTopTagsClient attClient = new ArtistTopTagsClient();
attClient.setWebserviceHistoryService(historyService);
attClient.setHttpClient(httpClient);
attClient.setThrottleService(throttleService);
return attClient;
}
use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.
the class JdbcUserLovedTracksDaoTest method deletesUnlovedTracksIdentifiedInImport.
@Test
public void deletesUnlovedTracksIdentifiedInImport() throws ApplicationException {
List<Track> lovedTracks = new UserLovedTracksParserImpl(new ResourceUtil(LOVED_TRACKS_FILE).getInputStream()).getLovedTracks();
dao.createLovedTracks(asList(new UserLovedTracks(USERNAME1, lovedTracks)));
lovedTracks.remove(0);
dao.createLovedTracks(asList(new UserLovedTracks(USERNAME1, lovedTracks)));
List<Track> dbLovedTracks = dao.getLovedTracks(USERNAME1);
Collections.sort(lovedTracks);
Collections.sort(dbLovedTracks);
assertEquals(lovedTracks, dbLovedTracks);
}
use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.
the class JdbcUserLovedTracksDaoTest method createAndRetrievesUserLovedTracks.
@Test
public void createAndRetrievesUserLovedTracks() throws ApplicationException {
List<Track> lovedTracks = new UserLovedTracksParserImpl(new ResourceUtil(LOVED_TRACKS_FILE).getInputStream()).getLovedTracks();
dao.createLovedTracks(asList(new UserLovedTracks(USERNAME1, lovedTracks)));
List<Track> dbLovedTracks = dao.getLovedTracks(USERNAME1);
Collections.sort(lovedTracks);
Collections.sort(dbLovedTracks);
assertEquals(lovedTracks, dbLovedTracks);
}
use of com.github.hakko.musiccabinet.util.ResourceUtil in project musiccabinet by hakko.
the class JdbcUserRecommendedArtistsDaoTest method loadFunctionDependency.
@Before
public void loadFunctionDependency() throws ApplicationException {
PostgreSQLUtil.loadFunction(dao, UPDATE_USER_RECOMMENDED_ARTISTS);
joanRec = new UserRecommendedArtists(joan, new UserRecommendedArtistsParserImpl(new ResourceUtil(JOAN_FILE).getInputStream()).getArtists());
rjRec = new UserRecommendedArtists(rj, new UserRecommendedArtistsParserImpl(new ResourceUtil(RJ_FILE).getInputStream()).getArtists());
String body = new WSResponse(new ResourceUtil(FTPAREA_FILE).getContent()).getResponseBody();
ftpareaRec = new UserRecommendedArtists(ftparea, new UserRecommendedArtistsParserImpl(new StringUtil(body).getInputStream()).getArtists());
createArtistMetaData();
}
Aggregations