From 1da07465b60a8e357373d7c3a3f764dfa4d5960b Mon Sep 17 00:00:00 2001 From: nea Date: Sun, 6 Aug 2023 23:03:06 +0200 Subject: Basic test for dungeon items --- .../at/hannibal2/skyhanni/test/BootstrapHook.kt | 30 ++++++++++++++++++++++ .../at/hannibal2/skyhanni/test/ItemModifierTest.kt | 28 ++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/test/java/at/hannibal2/skyhanni/test/BootstrapHook.kt create mode 100644 src/test/java/at/hannibal2/skyhanni/test/ItemModifierTest.kt (limited to 'src/test/java/at') diff --git a/src/test/java/at/hannibal2/skyhanni/test/BootstrapHook.kt b/src/test/java/at/hannibal2/skyhanni/test/BootstrapHook.kt new file mode 100644 index 000000000..3aff72c2b --- /dev/null +++ b/src/test/java/at/hannibal2/skyhanni/test/BootstrapHook.kt @@ -0,0 +1,30 @@ +package at.hannibal2.skyhanni.test + +import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible +import net.minecraft.block.Block +import net.minecraft.block.BlockFire +import net.minecraft.init.Bootstrap +import net.minecraft.item.Item +import org.junit.jupiter.api.extension.BeforeAllCallback +import org.junit.jupiter.api.extension.Extension +import org.junit.jupiter.api.extension.ExtensionContext +import java.util.concurrent.locks.Lock +import java.util.concurrent.locks.ReentrantLock + +class BootstrapHook : BeforeAllCallback, Extension { + companion object { + private val LOCK: Lock = ReentrantLock() + } + + override fun beforeAll(p0: ExtensionContext?) { + LOCK.lock() + try { + Bootstrap::class.java.getDeclaredField("alreadyRegistered").makeAccessible().set(null, true) + Block.registerBlocks() + BlockFire.init() + Item.registerItems() + } finally { + LOCK.unlock() + } + } +} \ No newline at end of file diff --git a/src/test/java/at/hannibal2/skyhanni/test/ItemModifierTest.kt b/src/test/java/at/hannibal2/skyhanni/test/ItemModifierTest.kt new file mode 100644 index 000000000..0fc172230 --- /dev/null +++ b/src/test/java/at/hannibal2/skyhanni/test/ItemModifierTest.kt @@ -0,0 +1,28 @@ +package at.hannibal2.skyhanni.test + +import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getDungeonStarCount +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHotPotatoCount +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getItemUuid +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasArtOfPeace +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated +import org.junit.jupiter.api.Test + +class ItemModifierTest { + + + @Test + fun testUpgradeLevelMasterStars() { + val itemStack = TestExportTools.getTestData(TestExportTools.Item, "10starnecronhead") + assert(!itemStack.isRecombobulated()) + assert(itemStack.getReforgeName() == "ancient") + assert(itemStack.getItemUuid() == "2810b7fe-33af-4dab-bb41-b4815f5847af") + assert(itemStack.isEnchanted()) + assert(itemStack.getHotPotatoCount() == 15) + assert(itemStack.getEnchantments()?.size == 11) + assert(itemStack.hasArtOfPeace()) + assert(itemStack.getDungeonStarCount() == 10) + } +} \ No newline at end of file -- cgit