Search in sources :

Example 21 with SpectatorBuilder

use of no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder in project L4J8 by stelar7.

the class CacheTest method testCacheStuff.

@Test
@Disabled
public void testCacheStuff() throws InterruptedException {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.INFO);
    System.out.println("Fetching summoner for the first time");
    DataCall.setCacheProvider(fileCache.get());
    String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    Thread.sleep(6000);
    System.out.println("Fetching summoner after cache timeout");
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", LeagueShard.EUW1);
    data.put("name", id);
    DataCall.getCacheProvider().clear(URLEndpoint.V4_SUMMONER_BY_NAME, data);
    System.out.println("Fetching summoner after deleting entry");
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    CacheLifetimeHint defaults = CacheLifetimeHint.DEFAULTS;
    defaults.add(URLEndpoint.V4_SUMMONER_BY_NAME, TimeUnit.SECONDS.toMillis(1));
    DataCall.getCacheProvider().setTimeToLive(defaults);
    Thread.sleep(1000);
    System.out.println("Fetching summoner after setting lifetime to a lower limit");
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
}
Also used : SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) CacheLifetimeHint(no.stelar7.api.r4j.basic.cache.CacheLifetimeHint) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Aggregations

SpectatorBuilder (no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)17 SummonerBuilder (no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder)16 Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)14 SpectatorBuilder (no.stelar7.api.l4j8.impl.builders.spectator.SpectatorBuilder)4 ChampionMasteryBuilder (no.stelar7.api.r4j.impl.lol.builders.championmastery.ChampionMasteryBuilder)4 L4J8 (no.stelar7.api.l4j8.impl.L4J8)3 SpectatorGameInfo (no.stelar7.api.l4j8.pojo.spectator.SpectatorGameInfo)3 R4J (no.stelar7.api.r4j.impl.R4J)3 ChampionMastery (no.stelar7.api.r4j.pojo.lol.championmastery.ChampionMastery)3 SummonerBuilder (no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)2 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)2 CacheLifetimeHint (no.stelar7.api.r4j.basic.cache.CacheLifetimeHint)2 LOLMatch (no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch)2 SpectatorGameInfo (no.stelar7.api.r4j.pojo.lol.spectator.SpectatorGameInfo)2 MatchListBuilder (no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)1 URLEndpoint (no.stelar7.api.r4j.basic.constants.api.URLEndpoint)1 LeagueBuilder (no.stelar7.api.r4j.impl.lol.builders.league.LeagueBuilder)1 MatchListBuilder (no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder)1 LeagueEntry (no.stelar7.api.r4j.pojo.lol.league.LeagueEntry)1