Package com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation

Examples of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype


    PostgreSQLUtil.loadFunction(dao, BLOCK_WEBSERVICE);
  }
 
  @Test
  public void importPageFromPersonLibraryNotPossibleTwice() {
    Calltype LIB = Calltype.GET_SCROBBLED_TRACKS;
    short page3 = 3;
    short page4 = 4;
    WebserviceInvocation libPage3 = new WebserviceInvocation(LIB, page3);
    WebserviceInvocation libPage4 = new WebserviceInvocation(LIB, page4);
View Full Code Here


    assertFalse(dao.isWebserviceInvocationAllowed(libPage4));
  }

  @Test
  public void importArtistTopTracksNotPossibleTwice() {
    Calltype TOP = Calltype.ARTIST_GET_TOP_TRACKS;
    Artist artist1 = new Artist("Esben And The Witch");
    Artist artist2 = new Artist("Espers");
    Artist artist3 = new Artist("Essie Jain");
    WebserviceInvocation topArtist1 = new WebserviceInvocation(TOP, artist1);
    WebserviceInvocation topArtist2 = new WebserviceInvocation(TOP, artist2);
View Full Code Here

    assertFalse(dao.isWebserviceInvocationAllowed(topArtist3));
  }
 
  @Test
  public void webserviceHistoryIsCaseInsensitive() {
    Calltype TOP = Calltype.ARTIST_GET_TOP_TRACKS;
    Artist artist1 = new Artist("Håll Det Äkta");
    Artist artist2 = new Artist("HÅLL DET ÄKTA");
    WebserviceInvocation topArtist1 = new WebserviceInvocation(TOP, artist1);
    WebserviceInvocation topArtist2 = new WebserviceInvocation(TOP, artist2);
   
View Full Code Here

    assertFalse(dao.isWebserviceInvocationAllowed(topArtist2));
  }
 
  @Test
  public void importArtistSimilaritiesAndTopTracksWorkIndependently() {
    Calltype TOP = Calltype.ARTIST_GET_TOP_TRACKS;
    Calltype SIMILAR = Calltype.ARTIST_GET_SIMILAR;
    Artist artist1 = new Artist("Björk");
    Artist artist2 = new Artist("Björn Olsson");

    WebserviceInvocation topArtist1 = new WebserviceInvocation(TOP, artist1);
    WebserviceInvocation topArtist2 = new WebserviceInvocation(TOP, artist2);
View Full Code Here

    assertTrue(dao.isWebserviceInvocationAllowed(similarArtist2));
  }
 
  @Test
  public void importTrackSimilaritiesIsNotPossibleTwice() {
    Calltype SIMILAR = Calltype.TRACK_GET_SIMILAR;
    Artist artist = new Artist("Bill Fay");
    Track track1 = new Track(artist, "Omega");
    Track track2 = new Track(artist, "Don't let my marigolds die");
   
    WebserviceInvocation similarTrack1 = new WebserviceInvocation(SIMILAR, track1);
View Full Code Here

    assertFalse(dao.isWebserviceInvocationAllowed(similarTrack2));
  }
 
  @Test
  public void importTrackSimilaritiesIsPossibleForCovers() {
    Calltype SIMILAR = Calltype.TRACK_GET_SIMILAR;
    Track track1 = new Track("Daniel Johnston", "True Love Will Find You In The End");
    Track track2 = new Track("Headless Heroes", "True Love Will Find You In The End");

    WebserviceInvocation similarTrack1 = new WebserviceInvocation(SIMILAR, track1);
    WebserviceInvocation similarTrack2 = new WebserviceInvocation(SIMILAR, track2);
View Full Code Here

    assertFalse(dao.isWebserviceInvocationAllowed(similarTrack2));
  }

  @Test
  public void oldInvocationsAreIgnored() {
    Calltype SIMILAR = Calltype.TRACK_GET_SIMILAR;
    Track track = new Track("Red Sparowes", "Finally, As That Blazing Sun Shone Down Upon Us, Did We Know That True Enemy Was the Voice of Blind Idolatry; and Only Then Did We Begin to Think for Ourselves.");
    WebserviceInvocation similarTrack = new WebserviceInvocation(SIMILAR, track);

    deleteWebserviceInvocations();

    assertTrue(dao.isWebserviceInvocationAllowed(similarTrack));
    dao.logWebserviceInvocation(similarTrack);
    assertFalse(dao.isWebserviceInvocationAllowed(similarTrack));

    // make the invocation age in database, by updating it.
    DateTime dateTime = new DateTime();
    JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
    for (int days = 1; days <= 14; days++) {
      jdbcTemplate.update("update library.webservice_history set invocation_time = ?",
          new Object[]{dateTime.minusDays(days).toDate()});
      boolean isAllowed = dao.isWebserviceInvocationAllowed(similarTrack);
      boolean cacheIsInvalid = days > SIMILAR.getDaysToCache();
      assertTrue(isAllowed == cacheIsInvalid);
    }
  }
View Full Code Here

    }
  }

  @Test
  public void importUserRelatedDataNotPossibleTwice() {
    Calltype TOP_ARTISTS = Calltype.USER_GET_TOP_ARTISTS;
    LastFmUser user = new LastFmUser("arnathalon");
    WebserviceInvocation topArtists = new WebserviceInvocation(TOP_ARTISTS, user, OVERALL.getDays());
   
    deleteWebserviceInvocations();
   
View Full Code Here

    assertFalse(dao.isWebserviceInvocationAllowed(topArtists));
  }

  @Test
  public void periodIsSignificantForAllowance() {
    Calltype TOP_ARTISTS = Calltype.USER_GET_TOP_ARTISTS;
    LastFmUser user = new LastFmUser("arnathalon");
    WebserviceInvocation topArtists1 = new WebserviceInvocation(TOP_ARTISTS, user, OVERALL.getDays());
    WebserviceInvocation topArtists2 = new WebserviceInvocation(TOP_ARTISTS, user, SIX_MONTHS.getDays());

    deleteWebserviceInvocations();
View Full Code Here

    assertFalse(dao.isWebserviceInvocationAllowed(topArtists2));
  }
 
  @Test
  public void differentUsersDontInterfere() {
    Calltype TOP_ARTISTS = Calltype.USER_GET_TOP_ARTISTS;
    LastFmUser user1 = new LastFmUser("user1");
    LastFmUser user2 = new LastFmUser("user2");

    WebserviceInvocation topArtists1 = new WebserviceInvocation(TOP_ARTISTS, user1, OVERALL.getDays());
    WebserviceInvocation topArtists2 = new WebserviceInvocation(TOP_ARTISTS, user2, OVERALL.getDays());
View Full Code Here

TOP

Related Classes of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype

Copyright © 2018 www.massapicom. 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.