Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.2 Lodestone Updates #57

Merged
merged 3 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ public interface LodestonePageLoader {
*/
Document getCharacterPage(final int characterId) throws IOException, InterruptedException, CharacterDeletedException;

/**
* Fetches a Character's Class & Job info, where available.
* @param characterId
* @return
* @throws IOException
* @throws InterruptedException
* @throws CharacterDeletedException
*/
Document getClassJobPage(final int characterId) throws IOException, InterruptedException, CharacterDeletedException;

/**
* Fetches a Characters Minions page, where available.
* @param characterId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ProductionLodestonePageLoader implements LodestonePageLoader {

/** Logger */
private static final Logger LOG = LoggerFactory.getLogger(ProductionLodestonePageLoader.class);
/** URL fragment for Classes & Jobs */
private static final String SECTION_CLASS_JOB = "class_job";
/** URL fragment for Minions. */
private static final String SECTION_MINIONS = "minion";
/** URL fragment for Mounts. */
Expand All @@ -46,6 +48,11 @@ public Document getCharacterPage(final int characterId) throws IOException, Inte
return getPage(baseUrl, characterId, 1);
}

@Override
public Document getClassJobPage(int characterId) throws IOException, InterruptedException, CharacterDeletedException {
return getPage(baseUrl + SECTION_CLASS_JOB, characterId, 1);
}

@Override
public Document getMinionPage(int characterId) throws IOException, InterruptedException, CharacterDeletedException {
return getPage(baseUrl + SECTION_MINIONS, characterId, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ public PlayerBean getPlayer(final int playerID) throws IOException, InterruptedE
player.setGrandCompany(getGrandCompanyFromPage(doc));
player.setFreeCompany(getFreeCompanyFromPage(doc));
player.setDateImgLastModified(getDateLastUpdatedFromPage(doc, playerID));
setLevels(player, getLevelsFromPage(doc));

Document classJobDoc = pageLoader.getClassJobPage(playerID);
setLevels(player, getLevelsFromPage(classJobDoc));

// Mounts from the relevant sub-section
Document mountDoc = pageLoader.getMountPage(playerID);
Expand Down Expand Up @@ -366,7 +368,7 @@ private int[] getLevelsFromPage(final Document doc) {
// Initialize array list in which to store levels (in order displayed on lodestone)
List<Integer> levels = new ArrayList<>();

Element classJobTab = doc.getElementsByClass("character__content").get(2);
Element classJobTab = doc.getElementsByClass("character__content").get(0);
for(Element jobLevel : classJobTab.getElementsByClass(LAYOUT_CHARACTER_JOB_LEVEL)) {
String strLvl = jobLevel.text();
if(strLvl.equals("-")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ public Document getCharacterPage(int characterId) throws IOException, Interrupte
}
return doc;
}

@Override
public Document getClassJobPage(int characterId) throws IOException, InterruptedException, CharacterDeletedException {
Document doc;
try {
doc = Jsoup.parse(
new File(
this.getClass().getResource(
String.format("/data/lodestone/Character-%d-Class-Jobs.html", characterId))
.toURI()),
null);
} catch(Exception e) {
throw new RuntimeException();
}
return doc;
}

@Override
public Document getMinionPage(int characterId) throws IOException, InterruptedException, CharacterDeletedException {
Expand Down Expand Up @@ -57,7 +73,7 @@ public Document getMountPage(int characterId) throws IOException, InterruptedExc

@Override
public Document getTooltipPage(String href) throws IOException, InterruptedException {
// TODO Auto-generated method stub
// TODO Provide a test stub here?
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testGetPlayer() throws Exception {
assertTrue(playerOne.getLevelThaumaturge() >= 60);
assertTrue(playerOne.getLevelArcanist() >= 60);
assertTrue(playerOne.getLevelRedmage() >= 70);
assertTrue(playerOne.getLevelBluemage() <= 50);
assertTrue(playerOne.getLevelBluemage() <= 60);

// Healer
assertTrue(playerOne.getLevelConjurer() >= 60);
Expand Down Expand Up @@ -199,14 +199,14 @@ public void testGetVeteranPlayer() throws Exception {
}

/**
* Perform a test of the getPlayer method using character #13002145 (Mi Clay, Yojimbo) to test data
* Perform a test of the getPlayer method using character #13002145 (Momo Haru, Fenrir) to test data
* that could not be tested with other tests.
*
* @throws Exception Exception exception thrown when reading non-existant character.
*/
@Test
public void testUnplayedPlayer() throws Exception {
PlayerBean player = instance.getPlayer(13002142);
PlayerBean player = instance.getPlayer(1557282);

// Test grand company
assertEquals("none", player.getGrandCompany());
Expand All @@ -215,8 +215,8 @@ public void testUnplayedPlayer() throws Exception {
// Test gender
assertEquals("male", player.getGender());

// Test that classes are polling correctly, arcanist level will be indicated on page by '-' should be 0 in player object.
assertEquals(0, player.getLevelArcanist());
// Test that classes are polling correctly, pugilist level will be indicated on page by '-' should be 0 in player object.
assertEquals(0, player.getLevelPugilist());

// Test fields that are true in other tests
assertFalse(player.isHas30DaysSub());
Expand Down Expand Up @@ -249,7 +249,7 @@ public void testUnplayedPlayer() throws Exception {

// Test get minions method
assertTrue(player.getMinions().size() == 0);
assertTrue(player.getMounts().size() == 0);
assertTrue(player.getMounts().size() <= 1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
public class PlayerBuilderTest {

private PlayerBuilder instance;
private static EorzeaDatabaseCache EDB_CACHE = new EorzeaDatabaseCache();

@Before
public void setUp() {
instance = new PlayerBuilder();
// TODO: Figure out a mock of this
instance.setEorzeaDatabaseCache(new EorzeaDatabaseCache());
instance.setEorzeaDatabaseCache(EDB_CACHE);
}

@Test
Expand All @@ -40,45 +41,45 @@ public void testLoadFrom2256025() throws Exception {
// Tank
assertEquals(0, player.getLevelGladiator());
assertEquals(0, player.getLevelMarauder());
assertEquals(70, player.getLevelDarkknight());
assertEquals(74, player.getLevelGunbreaker());
assertEquals(80, player.getLevelDarkknight());
assertEquals(80, player.getLevelGunbreaker());

// Melee DPS
assertEquals(70, player.getLevelPugilist());
assertEquals(37, player.getLevelLancer());
assertEquals(80, player.getLevelPugilist());
assertEquals(50, player.getLevelLancer());
assertEquals(55, player.getLevelRogue());
assertEquals(70, player.getLevelSamurai());

// Ranged Physical DPS
assertEquals(80, player.getLevelArcher());
assertEquals(80, player.getLevelMachinist());
assertEquals(60, player.getLevelDancer());
assertEquals(80, player.getLevelDancer());

// Ranged Magical DPS
assertEquals(70, player.getLevelThaumaturge());
assertEquals(80, player.getLevelArcanist());
assertEquals(70, player.getLevelRedmage());
assertEquals(50, player.getLevelBluemage());
assertEquals(73, player.getLevelRedmage());
assertEquals(60, player.getLevelBluemage());

// Healer
assertEquals(70, player.getLevelConjurer());
assertEquals(80, player.getLevelConjurer());
assertEquals(80, player.getLevelScholar());
assertEquals(70, player.getLevelAstrologian());
assertEquals(80, player.getLevelAstrologian());

// Disciples of the hand
assertEquals(27, player.getLevelCarpenter());
assertEquals(13, player.getLevelBlacksmith());
assertEquals(17, player.getLevelArmorer());
assertEquals(69, player.getLevelCarpenter());
assertEquals(28, player.getLevelBlacksmith());
assertEquals(25, player.getLevelArmorer());
assertEquals(21, player.getLevelGoldsmith());
assertEquals(0, player.getLevelLeatherworker());
assertEquals(0, player.getLevelWeaver());
assertEquals(21, player.getLevelAlchemist());
assertEquals(33, player.getLevelCulinarian());
assertEquals(80, player.getLevelAlchemist());
assertEquals(70, player.getLevelCulinarian());

// Disciples of the land
assertEquals(0, player.getLevelMiner());
assertEquals(50, player.getLevelBotanist());
assertEquals(78, player.getLevelFisher());
assertEquals(58, player.getLevelBotanist());
assertEquals(80, player.getLevelFisher());

// The Forbidden Land, Eureka
assertEquals(60, player.getLevelEureka());
Expand Down Expand Up @@ -163,7 +164,7 @@ public void testLoadFrom22763008() throws Exception {
// Test classes - levels based on those at time of test creation
// Tank
assertEquals(0, player.getLevelGladiator());
assertEquals(28, player.getLevelMarauder());
assertEquals(33, player.getLevelMarauder());
assertEquals(0, player.getLevelDarkknight());
assertEquals(0, player.getLevelGunbreaker());

Expand Down
Loading