diff options
| author | Moritz <59416038+Morazzer@users.noreply.github.com> | 2025-01-25 18:57:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-26 01:57:09 +0800 |
| commit | f73a04e4eb009cb15066c20f233fd6f11c87511e (patch) | |
| tree | 611af864dac553465f2d8732f107cac97e925cf0 /src/test/java | |
| parent | 76f0b6ea632cdef87e1791c8d96a2fbf586ef81f (diff) | |
| download | Skyblocker-f73a04e4eb009cb15066c20f233fd6f11c87511e.tar.gz Skyblocker-f73a04e4eb009cb15066c20f233fd6f11c87511e.tar.bz2 Skyblocker-f73a04e4eb009cb15066c20f233fd6f11c87511e.zip | |
add enchantment abbreviations as slot text (#1056)
* add enchantment abbreviations as slot text
* Refactor and clean up
* Move verification to unit test
* Refactor, now this is clean code
---------
Co-authored-by: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/de/hysky/skyblocker/skyblock/item/slottext/adders/EnchantmentLevelAdderTest.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/java/de/hysky/skyblocker/skyblock/item/slottext/adders/EnchantmentLevelAdderTest.java b/src/test/java/de/hysky/skyblocker/skyblock/item/slottext/adders/EnchantmentLevelAdderTest.java new file mode 100644 index 00000000..90d6191f --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/skyblock/item/slottext/adders/EnchantmentLevelAdderTest.java @@ -0,0 +1,28 @@ +package de.hysky.skyblocker.skyblock.item.slottext.adders; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimaps; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +public class EnchantmentLevelAdderTest { + @Test + void testEnchantmentAbbreviations() { + checkForDuplicates(EnchantmentLevelAdder.ENCHANTMENT_ABBREVIATIONS); + } + + @Test + void testUltimateEnchantmentAbbreviations() { + checkForDuplicates(EnchantmentLevelAdder.ULTIMATE_ENCHANTMENT_ABBREVIATIONS); + } + + private void checkForDuplicates(Map<String, String> abbreviations) { + if (abbreviations.size() == abbreviations.values().stream().distinct().count()) return; + abbreviations.entrySet().stream().collect(Multimaps.toMultimap(Map.Entry::getValue, Map.Entry::getKey, ArrayListMultimap::create)) + .asMap().entrySet().stream().filter(e -> e.getValue().size() > 1) + .map(e -> "Duplicate abbreviations: %s for %s".formatted(e.getKey(), e.getValue())) + .forEach(Assertions::fail); + } +} |
