Search in sources :

Example 6 with SpectatorBuilder

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

the class FeaturedGameTest method testCurrentGame.

@Test
public void testCurrentGame() {
    final R4J r4J = new R4J(SecretFile.CREDS);
    SpectatorBuilder sb = new SpectatorBuilder().withPlatform(LeagueShard.EUW1);
    final List<SpectatorGameInfo> game = sb.getFeaturedGames();
    doAssertions.accept(game);
}
Also used : SpectatorGameInfo(no.stelar7.api.r4j.pojo.lol.spectator.SpectatorGameInfo) R4J(no.stelar7.api.r4j.impl.R4J) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Example 7 with SpectatorBuilder

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

the class CacheTest method doCacheStuff.

private void doCacheStuff() throws InterruptedException {
    // DataCall.getCacheProvider().clear(URLEndpoint.V3_MATCH);
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    loggerContext.getLogger("no.stelar7.api.r4j.basic.calling.DataCallBuilder").setLevel(Level.INFO);
    loggerContext.getLogger("no.stelar7.api.r4j.basic.ratelimiting.BurstRateLimiter").setLevel(Level.OFF);
    loggerContext.getLogger("no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider").setLevel(Level.OFF);
    System.out.println("Fetching a random summoner and their match list");
    String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
    Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    List<String> recents = new MatchListBuilder().withPlatform(LeagueShard.EUW1).withPuuid(s.getPUUID()).get();
    if (recents.isEmpty()) {
        return;
    }
    String ref = recents.get(0);
    System.out.println("Starting timer");
    long start = System.currentTimeMillis();
    LOLMatch url = LOLMatch.get(LeagueShard.EUW1, ref);
    System.out.printf("1x url fetch time: %dns%n", System.currentTimeMillis() - start);
    start = System.currentTimeMillis();
    LOLMatch cached = LOLMatch.get(LeagueShard.EUW1, ref);
    System.out.printf("1x cache fetch time: %dns%n", System.currentTimeMillis() - start);
    if (!url.equals(cached)) {
        throw new RuntimeException("CACHE IS BROKEN!!!!");
    }
    start = System.currentTimeMillis();
    for (int i = 0; i < 10; i++) {
        LOLMatch.get(LeagueShard.EUW1, ref);
    }
    System.out.printf("10x cache fetch time: %dns%n", System.currentTimeMillis() - start);
    System.out.println();
    start = System.currentTimeMillis();
    LOLMatch.get(LeagueShard.EUW1, ref);
    System.out.printf("1x cache fetch time: %dns%n", System.currentTimeMillis() - start);
    System.out.println();
    System.out.println("clearing cache");
    System.out.println();
    DataCall.getCacheProvider().clear(URLEndpoint.V5_MATCH, Collections.emptyMap());
    start = System.currentTimeMillis();
    LOLMatch.get(LeagueShard.EUW1, ref);
    System.out.printf("1x url fetch time: %dns%n", System.currentTimeMillis() - start);
    start = System.currentTimeMillis();
    for (int i = 0; i < 10; i++) {
        LOLMatch.get(LeagueShard.EUW1, ref);
    }
    System.out.printf("10x cache fetch same item time: %dns%n", System.currentTimeMillis() - start);
    System.out.println();
    System.out.println("Fetching 3 aditional matches");
    LOLMatch.get(LeagueShard.EUW1, recents.get(1));
    LOLMatch.get(LeagueShard.EUW1, recents.get(2));
    LOLMatch.get(LeagueShard.EUW1, recents.get(3));
    System.out.printf("Cache size: %d%n", DataCall.getCacheProvider().getSize(URLEndpoint.V5_MATCH, Collections.emptyMap()));
    System.out.println("Waiting for cache timeout");
    TimeUnit.SECONDS.sleep(6);
    System.out.printf("Cache size: %d%n", DataCall.getCacheProvider().getSize(URLEndpoint.V5_MATCH, Collections.emptyMap()));
    System.out.println("Re-fetching cached items");
    start = System.currentTimeMillis();
    LOLMatch.get(LeagueShard.EUW1, recents.get(0));
    LOLMatch.get(LeagueShard.EUW1, recents.get(1));
    LOLMatch.get(LeagueShard.EUW1, recents.get(2));
    LOLMatch.get(LeagueShard.EUW1, recents.get(3));
    System.out.printf("4x fetches took: %dns%n", System.currentTimeMillis() - start);
    System.out.printf("Cache size: %d%n", DataCall.getCacheProvider().getSize(URLEndpoint.V5_MATCH, Collections.emptyMap()));
    System.out.println();
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder) LOLMatch(no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder) CacheLifetimeHint(no.stelar7.api.r4j.basic.cache.CacheLifetimeHint) URLEndpoint(no.stelar7.api.r4j.basic.constants.api.URLEndpoint)

Example 8 with SpectatorBuilder

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

the class SummonerTest method testByAccount.

@Test
public void testByAccount() {
    String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
    Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    Summoner optional = new SummonerBuilder().withPlatform(s.getPlatform()).withAccountId(s.getAccountId()).get();
    doAssertions.accept(optional);
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Example 9 with SpectatorBuilder

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

the class CurrentGameTest method testCurrentGame.

@Test
public void testCurrentGame() {
    final L4J8 l4j8 = new L4J8(SecretFile.CREDS);
    SpectatorBuilder sb = new SpectatorBuilder().withPlatform(Platform.EUW1);
    // Get a game in progess
    final List<SpectatorGameInfo> game = sb.getFeaturedGames();
    // Get a summoner from that game
    final String name = game.get(0).getParticipants().get(0).getSummonerName();
    final Summoner sum = new SummonerBuilder().withPlatform(Constants.TEST_PLATFORM[0]).withName(name).get();
    // Get game info
    final SpectatorGameInfo currentGame = sb.withSummonerId(sum.getSummonerId()).getCurrentGame();
    if (currentGame != null) {
        doAssertions.accept(currentGame);
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SpectatorGameInfo(no.stelar7.api.l4j8.pojo.spectator.SpectatorGameInfo) L4J8(no.stelar7.api.l4j8.impl.L4J8) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) SpectatorBuilder(no.stelar7.api.l4j8.impl.builders.spectator.SpectatorBuilder)

Example 10 with SpectatorBuilder

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

the class CurrentGameTest method testCurrentlyNotInGame.

@Test
public void testCurrentlyNotInGame() {
    final L4J8 l4j8 = new L4J8(SecretFile.CREDS);
    SpectatorBuilder sb = new SpectatorBuilder().withPlatform(Constants.TEST_PLATFORM[0]).withSummonerId(Constants.TEST_SUMMONER_IDS[0]);
    SpectatorGameInfo game = sb.getCurrentGame();
    System.out.format("%s is %sin game%n", Constants.TEST_SUMMONER_NAMES[0], game != null ? "" : "not ");
}
Also used : SpectatorGameInfo(no.stelar7.api.l4j8.pojo.spectator.SpectatorGameInfo) L4J8(no.stelar7.api.l4j8.impl.L4J8) SpectatorBuilder(no.stelar7.api.l4j8.impl.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