use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.
the class TestTFTSummoner method testByAccount.
@Test
public void testByAccount() {
Summoner s = api.getSummonerByName(LeagueShard.EUW1, "stelar7");
Summoner optional = api.getSummonerByAccount(LeagueShard.EUW1, s.getAccountId());
doAssertions.accept(optional);
}
use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.
the class RatelimitTest method testRateLimit.
@Test
@Disabled
public void testRateLimit() {
final R4J test = new R4J(SecretFile.CREDS);
String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
for (int i2 = 0; i2 < 130; i2++) {
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
}
}
use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner 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();
}
use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.
the class SummonerTest method testWadas.
@Test
public void testWadas() {
DataCall.setCacheProvider(null);
Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUN1).withName("GindenEU").get();
Summoner s2 = new SummonerBuilder().withPlatform(LeagueShard.EUN1).withPUUID(s.getPUUID()).get();
System.out.println(s);
System.out.println(s2);
}
use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner 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);
}
Aggregations