Skip to content

Commit

Permalink
Also check keytype against cache data
Browse files Browse the repository at this point in the history
Fixes #95
  • Loading branch information
stelar7 committed Mar 26, 2024
1 parent e89b2da commit 0a8fd20
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public RiotAccount getAccountByTag(RegionShard server, String name, String tag,
data.put("platform", server);
data.put("name", Utils.normalizeString(name));
data.put("tag", Utils.normalizeString(tag));
data.put("keytype", keyType);

Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_SHARED_ACCOUNT_BY_TAG, data);
if (chl.isPresent())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.stelar7.api.r4j.tests.shared;

import no.stelar7.api.r4j.basic.constants.api.regions.*;
import no.stelar7.api.r4j.basic.constants.types.ApiKeyType;
import no.stelar7.api.r4j.impl.R4J;
import no.stelar7.api.r4j.pojo.shared.*;
import no.stelar7.api.r4j.tests.SecretFile;
Expand All @@ -11,22 +12,22 @@
public class TestSharedAccount
{
@Test
@Order(2)
public void getByPUUID()
@Order(1)
public void getByTag()
{
R4J api = new R4J(SecretFile.CREDS);
RiotAccount accountTag = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "STL7");
RiotAccount account = api.getAccountAPI().getAccountByPUUID(RegionShard.EUROPE, accountTag.getPUUID());
RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "STL7");

System.out.println(account);
}

@Test
@Order(1)
public void getByTag()
@Order(2)
public void getByPUUID()
{
R4J api = new R4J(SecretFile.CREDS);
RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "STL7");
R4J api = new R4J(SecretFile.CREDS);
RiotAccount accountTag = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "STL7");
RiotAccount account = api.getAccountAPI().getAccountByPUUID(RegionShard.EUROPE, accountTag.getPUUID());

System.out.println(account);
}
Expand All @@ -35,11 +36,23 @@ public void getByTag()
@Order(3)
public void getShards()
{
R4J api = new R4J(SecretFile.CREDS);
R4J api = new R4J(SecretFile.CREDS);
RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "STL7");
RiotAccountShard shard = api.getAccountAPI().getActiveShard(RegionShard.AMERICAS, ShardableGame.LOR, account.getPUUID());

System.out.println(shard);
System.out.println(shard.getShardAsEnum());
}

@Test
@Order(4)
public void getByTagDifferentKeyType()
{
R4J api = new R4J(SecretFile.CREDS);
RiotAccount accountLoL = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "STL7", ApiKeyType.LOL);
RiotAccount accountTfT = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "STL7", ApiKeyType.TFT);

System.out.println(accountLoL);
System.out.println(accountTfT);
}
}

0 comments on commit 0a8fd20

Please sign in to comment.