-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a skill type enum for getting mapped values to help prevent inv…
…alid parameters
- Loading branch information
1 parent
512fae3
commit 3fbaadd
Showing
8 changed files
with
75 additions
and
70 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
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package com.baseketbandit.runeapi; | ||
|
||
import com.baseketbandit.runeapi.entity.Skill; | ||
import com.baseketbandit.runeapi.entity.Type; | ||
import com.baseketbandit.runeapi.io.RequestHandler; | ||
|
||
import java.util.Map; | ||
|
||
public class RuneAPI { | ||
|
||
public static Map<String, Skill> getStats(String username) { | ||
public static Map<Type, Skill> getStats(String username) { | ||
return RequestHandler.doGetRequest(username.replace(" ", "%20")); | ||
} | ||
} |
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
28 changes: 0 additions & 28 deletions
28
src/main/java/com/baseketbandit/runeapi/entity/Skills.java
This file was deleted.
Oops, something went wrong.
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,34 @@ | ||
package com.baseketbandit.runeapi.entity; | ||
|
||
public enum Type { | ||
OVERALL("Overall"), | ||
ATTACK("Attack"), | ||
DEFENSE("Defense"), | ||
STRENGTH("Strength"), | ||
HITPOINTS("Hitpoints"), | ||
RANGED("Ranged"), | ||
PRAYER("Prayer"), | ||
MAGIC("Magic"), | ||
COOKING("Cooking"), | ||
WOODCUTTING("Woodcutting"), | ||
FLETCHING("Fletching"), | ||
FISHING("Fishing"), | ||
FIREMAKING("Firemaking"), | ||
CRAFTING("Crafting"), | ||
SMITHING("Smithing"), | ||
MINING("Mining"), | ||
HERBLORE("Herblore"), | ||
AGILITY("Agility"), | ||
THIEVING("Thieving"), | ||
SLAYER("Slayer"), | ||
FARMING("Farming"), | ||
RUNECRAFT("Runecraft"), | ||
HUNTER("Hunter"), | ||
CONSTRUCTION("Construction"); | ||
|
||
final String name; | ||
|
||
Type(String name) { | ||
this.name = name; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,51 +1,50 @@ | ||
package com.baseketbandit.runeapi; | ||
|
||
import com.baseketbandit.runeapi.entity.Skill; | ||
import com.baseketbandit.runeapi.entity.Type; | ||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class RuneAPITest { | ||
|
||
@Test | ||
public void getStats() { | ||
Map<String, Skill> stats = RuneAPI.getStats("xwr"); | ||
Map<Type, Skill> stats = RuneAPI.getStats("xwr"); | ||
assert(!stats.isEmpty()); | ||
assert(stats.size() == 24); | ||
|
||
for(Skill skill: stats.values()) { | ||
System.out.println(skill.getName() + " - " + skill.getLevel()); | ||
System.out.printf("%s: #%,d - %,d - %,dxp \n", skill.getName(), skill.getRank(), skill.getLevel(), skill.getExperience()); | ||
} | ||
} | ||
|
||
@Test | ||
public void getStatsNotFound() { | ||
Map<String, Skill> stats = RuneAPI.getStats("abcdefghijklmnopqrstuvwxyz"); | ||
for(Skill skill: stats.values()) { | ||
System.out.println(skill.getName() + " - " + skill.getLevel()); | ||
} | ||
Map<Type, Skill> stats = RuneAPI.getStats("abcdefghijklmnopqrstuvwxyz"); | ||
assert(stats.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void getStatsNameSpace() { | ||
Map<String, Skill> stats = RuneAPI.getStats("Iron Lewiso"); | ||
Map<Type, Skill> stats = RuneAPI.getStats("Iron Lewiso"); | ||
assert(!stats.isEmpty()); | ||
assert(stats.size() == 24); | ||
|
||
for(Skill skill: stats.values()) { | ||
System.out.println(skill.getName() + " - " + skill.getLevel()); | ||
} | ||
} | ||
|
||
@Test | ||
public void getStatsMapped() { | ||
Map<String, Skill> stats = RuneAPI.getStats("xwr"); | ||
Skill cooking = stats.get("Cooking"); | ||
System.out.println(cooking.getLevel()); | ||
} | ||
Map<Type, Skill> stats = RuneAPI.getStats("xwr"); | ||
assert(!stats.isEmpty()); | ||
assert(stats.size() == 24); | ||
|
||
Skill cooking = stats.get(Type.COOKING); | ||
assert(!cooking.getName().equals("")); | ||
|
||
@Test | ||
public void getStatsMappedLowercase() { | ||
Map<String, Skill> stats = RuneAPI.getStats("xwr"); | ||
Skill cooking = stats.get("Cooking"); | ||
System.out.println(cooking.getLevel()); | ||
} | ||
} |