Examples of ResourceUtil


Examples of com.github.hakko.musiccabinet.util.ResourceUtil

    Assert.assertNotNull(ts);
  }
 
  private int prepareTestdataForArtist() throws ApplicationException {
    ArtistSimilarityParser asParser = new ArtistSimilarityParserImpl(
        new ResourceUtil(CHER_SIMILAR_ARTISTS).getInputStream());
    artistRelationDao.createArtistRelations(
        asParser.getArtist(), asParser.getArtistRelations());

    ArtistTopTracksParser attParser = new ArtistTopTracksParserImpl(
        new ResourceUtil(CHER_TOP_TRACKS).getInputStream());
    artistTopTracksDao.createTopTracks(
        attParser.getArtist(), attParser.getTopTracks());
   
    List<File> files = new ArrayList<>();
    for (Track topTrack : attParser.getTopTracks()) {
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

  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);
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

    when(lastFmSettingsService.getLastFmUsers()).thenReturn(asList(user1, user2));
    when(lastFmSettingsService.isSyncStarredAndLovedTracks()).thenReturn(true);

    UserLovedTracksClient userLovedTracksClient = mock(UserLovedTracksClient.class);
    when(userLovedTracksClient.getUserLovedTracks(user1, (short) 0)).thenReturn(
        new WSResponse(new ResourceUtil(LOVED_TRACKS_FILE, UTF8).getContent()));
    when(userLovedTracksClient.getUserLovedTracks(user2, (short) 0)).thenReturn(
        new WSResponse(false, 403, "Forbidden"));

    UserLovedTracksService userLovedTracksService = new UserLovedTracksService();
    userLovedTracksService.setLastFmSettingsService(lastFmSettingsService);
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

    testWSClient.close();
   
    Assert.assertTrue(wsResponse.wasCallAllowed());
    Assert.assertTrue(wsResponse.wasCallSuccessful());
    Assert.assertEquals(wsResponse.getResponseBody(),
        new ResourceUtil(SIMILAR_TRACKS_RESOURCE).getContent());
  }
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

  @SuppressWarnings("unchecked")
  private TestWSGetClient getTestWSClient(
      boolean allowCalls, String responseURI) throws IOException {
    TestWSGetClient testWSClient = getTestWSClient(allowCalls);
    HttpClient httpClient = testWSClient.getHttpClient();
    String httpResponse = new ResourceUtil(responseURI).getContent();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);
    return testWSClient;
  }
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

  @Before
  public void loadFunctionDependencyAndTestdata() throws ApplicationException {
    PostgreSQLUtil.loadFunction(dao, UPDATE_ARTISTTOPTAG);

    ArtistTopTagsParser cherParser = new ArtistTopTagsParserImpl(
        new ResourceUtil(CHER_TOP_TAGS).getInputStream());
    ArtistTopTagsParser rihannaParser = new ArtistTopTagsParserImpl(
        new ResourceUtil(RIHANNA_TOP_TAGS).getInputStream());
    cherArtist = cherParser.getArtist();
    cherTopTags = cherParser.getTopTags();
    rihannaArtist = rihannaParser.getArtist();
    rihannaTopTags = rihannaParser.getTopTags();
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

  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);
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

    // create a HTTP client that always returns sampled scrobbled tracks from last.fm
    HttpClient httpClient = mock(HttpClient.class);
    ClientConnectionManager connectionManager = mock(ClientConnectionManager.class);
    when(httpClient.getConnectionManager()).thenReturn(connectionManager);
    String httpResponse = new ResourceUtil(SCROBBLED_TRACKS).getContent();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);

    // create a client out of the components above
    ScrobbledTracksClient stClient = new ScrobbledTracksClient();
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

    }
  }

  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);
View Full Code Here

Examples of com.github.hakko.musiccabinet.util.ResourceUtil

 
  private ArtistQueryClient getArtistQueryClient() throws ApplicationException {
    ArtistQueryClient client = Mockito.mock(ArtistQueryClient.class);
   
    Mockito.when(client.get(artistName)).thenReturn(
        new ResourceUtil("musicbrainz/xml/artistQuery.xml").getContent());
     
    return client;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.