Skip to content

Commit b89d326

Browse files
kevinthegreat1lineargraph
authored andcommitted
Add JUnit tests
1 parent 788feae commit b89d326

File tree

4 files changed

+82
-78
lines changed

4 files changed

+82
-78
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ the source code is licensed under the BSD-2-Clause License. The `gradlew`, `grad
2222
You will need to manually download the repository files. I would personally recommend making use of the E-Tag returned by
2323
https://github.com/NotEnoughUpdates/NotEnoughUpdates-REPO/archive/refs/heads/master.zip for simple applications. This
2424
library is available at https://repo.nea.moe/#/releases/moe/nea/neurepoparser/1.0.0. Check out the
25-
[TestMain.java](src/test/java/TestMain.java)
25+
[NEURepoParserTest.java](src/test/java/io/github/moulberry/repo/NEURepoParserTest.java)
2626

build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ repositories {
1919
dependencies {
2020
compileOnly("org.jetbrains:annotations:24.0.0")
2121
implementation("com.google.code.gson:gson:2.9.0")
22-
testImplementation("io.kotest:kotest-runner-junit5:5.3.1")
22+
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
23+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2324
}
2425

2526
lombok {
26-
version = "1.18.22"
27-
sha256 = ""
27+
version = "1.18.32"
28+
sha256 = "97574674e2a25f567a313736ace00df8787d443de316407d57fc877d9f19a65d"
2829
}
2930

3031
java {

src/test/java/TestMain.java

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package io.github.moulberry.repo;
2+
3+
import io.github.moulberry.repo.data.*;
4+
import org.junit.jupiter.api.Assertions;
5+
import org.junit.jupiter.api.Test;
6+
7+
import java.nio.file.Paths;
8+
import java.util.stream.Collectors;
9+
import java.util.stream.Stream;
10+
11+
public class NEURepoParserTest {
12+
@Test
13+
public void test() throws NEURepositoryException {
14+
System.out.printf("Parser v%s%n", NEURepositoryVersion.REPOSITORY_PARSER_VERSION);
15+
System.out.printf("Schema %d.%d%n", NEURepositoryVersion.REPOSITORY_SCHEMA_VERSION_MAJOR, NEURepositoryVersion.REPOSITORY_SCHEMA_VERSION_MINOR);
16+
17+
NEURepository repository = NEURepository.of(Paths.get("NotEnoughUpdates-REPO"));
18+
NEURecipeCache recipes = NEURecipeCache.forRepo(repository);
19+
repository.reload();
20+
System.out.println("unknown recipe types: " + repository.getItems().getItems().values().stream()
21+
.flatMap(it -> it.getRecipes().stream())
22+
.filter(it -> it instanceof NEUUnknownRecipe).map(it -> (NEUUnknownRecipe) it)
23+
.map(NEUUnknownRecipe::getType)
24+
.collect(Collectors.toSet()));
25+
Assertions.assertEquals("MINING", repository.getConstants().getPetLevelingData().getPetExpTypes().get("ROCK"));
26+
Assertions.assertEquals("PetNumbers.Stats(otherNumbers=[0.2, 0.1, 10.0, 0.2], statNumbers={ABILITY_DAMAGE=0.0, INTELLIGENCE=1.0})", repository.getConstants().getPetNumbers().get("SHEEP").get(Rarity.LEGENDARY).interpolatedStatsAtLevel(1).toString());
27+
Assertions.assertEquals("PetNumbers.Stats(otherNumbers=[74.74747474747474, 0.3787878787878788, 0.17424242424242425], statNumbers={STRENGTH=37.37373737373737, MAGIC_FIND=4.94949494949495, BONUS_ATTACK_SPEED=37.37373737373737})", repository.getConstants().getPetNumbers().get("GOLDEN_DRAGON").get(Rarity.LEGENDARY).interpolatedStatsAtLevel(150).toString());
28+
Assertions.assertEquals(200, repository.getConstants().getPetLevelingData().getPetLevelingBehaviourOverrides().get("GOLDEN_DRAGON").getMaxLevel());
29+
Assertions.assertEquals(175, repository.getConstants().getMisc().getRainbowNames().size());
30+
Assertions.assertEquals("Private Island", repository.getConstants().getMisc().getAreaNames().get("dynamic"));
31+
Assertions.assertEquals(12, repository.getConstants().getMisc().getMaxMinionLevel().get("BLAZE_GENERATOR"));
32+
Assertions.assertEquals("100000", repository.getConstants().getMisc().getSlayerCost().get(4));
33+
Assertions.assertEquals("MVP", repository.getConstants().getMisc().getRanks().get("SUPERSTAR").getTag());
34+
Assertions.assertEquals("[CANDY_RING, CANDY_ARTIFACT, CANDY_RELIC]", repository.getConstants().getMisc().getTalismanUpgrades().get("CANDY_TALISMAN").toString());
35+
Assertions.assertEquals(31, repository.getConstants().getMisc().getCredits().getLore().size());
36+
Assertions.assertEquals("{magic_find=5.0}", repository.getConstants().getBonuses().getPetRewards(115).toString());
37+
Assertions.assertEquals("{damage_increase=2.0999992, crit_chance=30.0}", repository.getConstants().getBonuses().getAccumulativeLevelingRewards("skill_combat", 60).toString());
38+
Assertions.assertEquals("Optional[PERFECT_AMETHYST_GEM]", repository.getConstants().getParents().getParent("FLAWED_AMETHYST_GEM").toString());
39+
Assertions.assertEquals("[bane_of_arthropods, cleave, critical, cubism, dragon_hunter, ender_slayer, execute, experience, fire_aspect, first_strike, giant_killer, impaling, knockback, lethality, life_steal, looting, luck, mana_steal, PROSECUTE, scavenger, sharpness, smite, syphon, titan_killer, thunderlord, thunderbolt, triple_strike, vampirism, venomous, vicious, ultimate_one_for_all, ultimate_soul_eater, ultimate_chimera, ultimate_combo, ultimate_swarm, ultimate_wise, smoldering, ultimate_inferno, ultimate_fatal_tempo, tabasco, champion, divine_gift]", repository.getConstants().getEnchants().getAvailableEnchants("SWORD").toString());
40+
Assertions.assertEquals("[bane_of_arthropods, smite, ultimate_one_for_all]", repository.getConstants().getEnchants().getConflictingEnchants("sharpness").toString());
41+
Assertions.assertEquals("EssenceCosts.EssenceCost(type=Crimson, essenceCosts={1=170, 2=190, 3=215, 4=240, 5=270, 6=300, 7=340, 8=390, 9=440, 10=500}, itemCosts={4=[§610,000 Coins], 5=[§625,000 Coins], 6=[§650,000 Coins], 7=[§6100,000 Coins], 8=[§6Heavy Pearl §8x3, §6250,000 Coins], 9=[§6Heavy Pearl §8x4, §6500,000 Coins], 10=[§6Heavy Pearl §8x5, §61,000,000 Coins]})", repository.getConstants().getEssenceCost().getCosts().get("HOT_CRIMSON_HELMET").toString());
42+
Assertions.assertEquals("Coordinate(x=138, y=66, z=129)", repository.getConstants().getFairySouls().getSoulLocations().get("hub").get(0).toString());
43+
Assertions.assertEquals(247, repository.getConstants().getFairySouls().getMaxSouls());
44+
Assertions.assertEquals("minecraft:diamond_sword", repository.getItems().getItemBySkyblockId("ASPECT_OF_THE_END").getMinecraftItemId());
45+
Assertions.assertFalse(repository.getItems().getItemBySkyblockId("ASPECT_OF_THE_END").isVanilla());
46+
Assertions.assertTrue(repository.getItems().getItemBySkyblockId("DIAMOND").isVanilla());
47+
Assertions.assertEquals("[NEUIngredient{TITANIUM_DRILL_4:1.000000}, NEUIngredient{SKYBLOCK_COIN:50000000.000000}, NEUIngredient{DIVAN_ALLOY:1.000000}]", ((NEUForgeRecipe) recipes.getRecipes().get("DIVAN_DRILL").stream().filter(NEUForgeRecipe.class::isInstance).findAny().get()).getInputs().toString());
48+
Assertions.assertEquals(864000, ((NEUKatUpgradeRecipe) recipes.getRecipes().get("BAL;4").stream().filter(NEUKatUpgradeRecipe.class::isInstance).findAny().get()).getSeconds());
49+
50+
int expTotal = 235268;
51+
int expLeft = expTotal;
52+
int level = 0;
53+
for (int expRequiredForThisLevel : repository.getConstants().getLeveling().getSkillExperienceRequiredPerLevel()) {
54+
if (expLeft > expRequiredForThisLevel) {
55+
level++;
56+
expLeft -= expRequiredForThisLevel;
57+
}
58+
}
59+
Assertions.assertEquals(235268, expTotal);
60+
Assertions.assertEquals(18, level);
61+
Assertions.assertEquals(12843, expLeft);
62+
63+
64+
Assertions.assertEquals("[x8-15, x10-18, x2-3, x8-15, x8-15, x3, x1-2, x0-2, x0-3, x5-6, x0-6, x0-3, x30-32, x2, x3-6, x1-2, .05% per Summoning Eye, .01% per Summoning Eye, 2% per Summoning Eye, 3% per Summoning Eye, .05% per Summoning Eye, .01% per Summoning Eye, 2% per Summoning Eye, 3% per Summoning Eye, x1-2, x1-2, .05% per Summoning Eye, .01% per Summoning Eye, 2% per Summoning Eye, 3% per Summoning Eye, x4-7, x8-15, x1-3, x1-3, x1-2, x1-2, x1-2, x1-2, .05% per Summoning Eye, .01% per Summoning Eye, 2% per Summoning Eye, 3% per Summoning Eye, x8-15, x8-15, §aUnommon 20%, x1, x-10, x1-3, §a20%, §a10%, .05% per Summoning Eye, .01% per Summoning Eye, 2% per Summoning Eye, 3% per Summoning Eye, x2-4, x2-3, x1-3, x1-4, x1-2, x8-15, x8-15, 5% per Hit, 5% per Hit, 4.5% per Hit, 0.0126% per Hit, 0.0054% per Hit, x1-2, x1-2, x2-3, x8-15, x8-15, x1-3, x1-2, .05% per Summoning Eye, .01% per Summoning Eye, 2% per Summoning Eye, 3% per Summoning Eye, x1-2, x1-3, x1-2, §fUncommon 25%, .05% per Summoning Eye, .01% per Summoning Eye, 2% per Summoning Eye, 3% per Summoning Eye, x32, x1-2, x1-2, x1-2, x2-3, x5, x1-2, x1-2, x1-2, x10-22, x2, x2-3, x1-3, x15-27, x18-41]", repository.getItems().getItems().values().stream()
65+
.flatMap(it -> it.getRecipes().stream())
66+
.flatMap(it -> {
67+
if (it instanceof NEUMobDropRecipe) {
68+
return ((NEUMobDropRecipe) it).getDrops().stream();
69+
}
70+
return Stream.empty();
71+
})
72+
.map(NEUMobDropRecipe.Drop::getChance)
73+
.filter(it -> it != null && !it.matches("\\d+(.\\d+)?+%"))
74+
.collect(Collectors.toList()).toString()
75+
);
76+
}
77+
}

0 commit comments

Comments
 (0)