-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0 release ready, added a couple of unit tests
- Loading branch information
Showing
7 changed files
with
175 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ gradle | |
src/main/java/Test.java | ||
src/src.iml | ||
build | ||
lol4j.iml | ||
lol4j.iml | ||
junit.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import lol4j.client.Lol4JClient; | ||
import lol4j.client.impl.Lol4JClientImpl; | ||
import lol4j.util.Region; | ||
import org.junit.BeforeClass; | ||
|
||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
/** | ||
* Created by Aaryn101 on 12/14/13. | ||
*/ | ||
public abstract class AbstractResourceImplTest { | ||
private static String apiKey = null; | ||
private static String summonerName = null; | ||
private static Long summonerId = null; | ||
private static Region region = null; | ||
private static Lol4JClient client = null; | ||
|
||
@BeforeClass | ||
public static void init() { | ||
Properties p = new Properties(); | ||
try { | ||
p.load(new FileReader(new File("junit.properties"))); | ||
apiKey = p.getProperty("api.key"); | ||
summonerName = p.getProperty("summoner.name"); | ||
summonerId = Long.parseLong(p.getProperty("summoner.id")); | ||
region = Region.valueOf(p.getProperty("region").toUpperCase()); | ||
client = new Lol4JClientImpl(apiKey); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static Lol4JClient getClient() { | ||
return client; | ||
} | ||
|
||
public static String getApiKey() { | ||
return apiKey; | ||
} | ||
|
||
public static String getSummonerName() { | ||
return summonerName; | ||
} | ||
|
||
public static Long getSummonerId() { | ||
return summonerId; | ||
} | ||
|
||
public static Region getRegion() { | ||
return region; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import lol4j.exception.InvalidRegionException; | ||
import lol4j.protocol.dto.champion.ChampionDto; | ||
import lol4j.protocol.dto.champion.ChampionListDto; | ||
import lol4j.util.Region; | ||
import org.junit.Assert; | ||
|
||
/** | ||
* Created by Aaryn101 on 12/13/13. | ||
*/ | ||
public class ChampionResourceImplTest extends AbstractResourceImplTest { | ||
@org.junit.Test | ||
public void test_getAllChampions() { | ||
ChampionListDto championList = getClient().getAllChampions(Region.NA, false); | ||
|
||
Assert.assertNotNull(championList); | ||
Assert.assertNotNull(championList.getChampions()); | ||
Assert.assertNotEquals(championList.getChampions().size(), 0); | ||
|
||
ChampionDto champion = championList.getChampions().get(0); | ||
Assert.assertNotNull(champion.getAttackRank()); | ||
Assert.assertNotNull(champion.getDefenseRank()); | ||
Assert.assertNotNull(champion.getDifficultyRank()); | ||
Assert.assertNotNull(champion.getId()); | ||
Assert.assertNotNull(champion.getMagicRank()); | ||
Assert.assertNotNull(champion.getName()); | ||
} | ||
|
||
@org.junit.Test | ||
public void test_getAllChampionsWithUnsupportedRegion() { | ||
boolean exceptionThrown = false; | ||
|
||
try { | ||
getClient().getAllChampions(Region.TR, false); | ||
} | ||
catch(InvalidRegionException e) { | ||
exceptionThrown = true; | ||
} | ||
|
||
Assert.assertTrue(exceptionThrown); | ||
} | ||
|
||
@org.junit.Test | ||
public void test_getAllChampionsWithNullRegion() { | ||
boolean exceptionThrown = false; | ||
|
||
try { | ||
getClient().getAllChampions(null, false); | ||
} | ||
catch(InvalidRegionException e) { | ||
exceptionThrown = true; | ||
} | ||
|
||
Assert.assertTrue(exceptionThrown); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import lol4j.exception.InvalidRegionException; | ||
import lol4j.protocol.dto.game.GameDto; | ||
import lol4j.protocol.dto.game.RecentGamesDto; | ||
import lol4j.util.Region; | ||
import org.junit.Assert; | ||
|
||
/** | ||
* Created by Aaryn101 on 12/14/13. | ||
*/ | ||
public class GameResourceImplTest extends AbstractResourceImplTest { | ||
@org.junit.Test | ||
public void test_getRecentGames() { | ||
RecentGamesDto recentGames = getClient().getRecentGames(getRegion(), getSummonerId()); | ||
|
||
Assert.assertNotNull(recentGames); | ||
Assert.assertNotNull(recentGames.getGames()); | ||
|
||
if (recentGames.getGames().size() > 0) { | ||
GameDto game = recentGames.getGames().get(0); | ||
|
||
Assert.assertNotNull(game.getCreateDateStr()); | ||
Assert.assertNotNull(game.getGameMode()); | ||
Assert.assertNotNull(game.getGameType()); | ||
Assert.assertNotNull(game.getStatistics()); | ||
Assert.assertNotEquals(game.getStatistics().size(), 0); | ||
Assert.assertNotNull(game.getSubType()); | ||
Assert.assertNotNull(game.getFellowPlayers()); | ||
Assert.assertNotEquals(game.getFellowPlayers().size(), 0); | ||
} | ||
} | ||
|
||
@org.junit.Test | ||
public void test_getRecentGamesWithUnsupportedRegion() { | ||
boolean exceptionThrown = false; | ||
|
||
try { | ||
getClient().getRecentGames(Region.TR, 0L); | ||
} | ||
catch(InvalidRegionException e) { | ||
exceptionThrown = true; | ||
} | ||
|
||
Assert.assertTrue(exceptionThrown); | ||
} | ||
|
||
@org.junit.Test | ||
public void test_getRecentGamesWithNullRegion() { | ||
boolean exceptionThrown = false; | ||
|
||
try { | ||
getClient().getRecentGames(null, 0L); | ||
} | ||
catch(InvalidRegionException e) { | ||
exceptionThrown = true; | ||
} | ||
|
||
Assert.assertTrue(exceptionThrown); | ||
} | ||
} |