From c563fc0584d18243d13a9ae2ccd2ecac631fb054 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 21 Nov 2024 13:31:13 +0100 Subject: [PATCH] Add tests for file skins --- .../tests/impl/api/skin/SkinFetcherTest.java | 29 ++++++++++++++++++ src/main/resources/testskin.png | Bin 0 -> 1547 bytes 2 files changed, 29 insertions(+) create mode 100644 src/main/resources/testskin.png diff --git a/src/main/java/de/oliver/fancynpcs/tests/impl/api/skin/SkinFetcherTest.java b/src/main/java/de/oliver/fancynpcs/tests/impl/api/skin/SkinFetcherTest.java index 02ca7be8..2a5e955e 100644 --- a/src/main/java/de/oliver/fancynpcs/tests/impl/api/skin/SkinFetcherTest.java +++ b/src/main/java/de/oliver/fancynpcs/tests/impl/api/skin/SkinFetcherTest.java @@ -1,11 +1,14 @@ package de.oliver.fancynpcs.tests.impl.api.skin; +import de.oliver.fancynpcs.FancyNpcs; import de.oliver.fancynpcs.api.skins.SkinData; import de.oliver.fancynpcs.skins.SkinFetcherImpl; import de.oliver.fancynpcs.tests.annotations.FNBeforeEach; import de.oliver.fancynpcs.tests.annotations.FNTest; import org.bukkit.entity.Player; +import java.io.File; + public class SkinFetcherTest { private SkinFetcherImpl skinFetcher; @@ -51,4 +54,30 @@ public void testSkinByURL(Player player) { assert skin.textureSignature() != null && !skin.textureSignature().isEmpty(); } + @FNTest(name = "Test fetch skin by file") + public void testSkinByFile(Player player) { + SkinData skin = skinFetcher.getByFile("plugins/FancyNpcs/testskin.png"); + FancyNpcs.getInstance().getPlugin().saveResource("testskin.png", false); + + assert skin != null; + assert skin.identifier().equals("src/test/resources/skin.png"); + assert skin.type().equals(SkinData.SkinType.FILE); + assert skin.variant().equals(SkinData.SkinVariant.DEFAULT); + assert skin.textureValue() != null && !skin.textureValue().isEmpty(); + assert skin.textureSignature() != null && !skin.textureSignature().isEmpty(); + + new File("plugins/FancyNpcs/testskin.png").delete(); + } + + @FNTest(name = "Test get skin") + public void testGetSkin(Player player) { + SkinData skin = skinFetcher.get("skinname", "value", "signature"); + + assert skin != null; + assert skin.identifier().equals("skinname"); + assert skin.type().equals(SkinData.SkinType.VALUE_SIGNATURE); + assert skin.variant().equals(SkinData.SkinVariant.DEFAULT); + assert skin.textureValue().equals("value"); + assert skin.textureSignature().equals("signature"); + } } diff --git a/src/main/resources/testskin.png b/src/main/resources/testskin.png new file mode 100644 index 0000000000000000000000000000000000000000..b841077cceeb2ba73c3170fb9280e0d9e4bed113 GIT binary patch literal 1547 zcmV+m2K4!fP)9lpT8(&k<&!l({p@;U z+Bn`WP+h08od^_s@BZ;aMfmRfTTQr*qAsqZd>n7v7+quJn~fB1p;bXFSaghh9Pgy? z^=aQZa)y%@ti+sL7Q=RqcN*xrwCx<8)ht5Jwu^9d>B0tG432kFCaioo8P{kU^G6L23V=W$2lCzXr+&MQ}#Z9eyPJQn>NJI7Za$E-U^h>jlEHu1UV zUuuHA+v{95`+NPJz?9z!I>~G&Mm~Z5EUb@t-h!NvKVU>JJAcuA{^gC;)6YEH3ZO@v z&SkT|*FOdK{OfEBczoK8DZemzeGiiNblSwxbAC?$k)H`ysNyPH503Tq)AkT9e|UXm zUc7vDb$tJ?)zO_hs~>Ouw7PNg+qzRgF^X5eq-^r#*l)h`-s*)HUt7KW>RYWXJI5n( zJn`zauNxV6VmxXE&}uv{z?m(;gFR!H1vvFBkb+4iRWV~EiX0W7;%LRt&H|A3Tc3;b z%Ij~pqY7?c14S>TRtA|#wx`E~HscsiPWdX@Z+%|1Z(O+8j#_Q@HBit}at1h?*=Af7 z-|I^|g`4hUeX{BJ?%`oO>bA45fr6Hj$yJHcZXXNK6I_wPdn-U=>Uiba$L*+F*uDk| zGQCMv%zc1~krX+_xv^YDypHwx{G*#+w4-viuYtl@go+u%1SlY9g>j5$U$&QUL*xh) zy_8&nm0-6SSH#aTRejQD+wvo#f_cP8Hzqdv{wBI{tC{_w_mB%-#y<6~L>bqQ|1nE-2d6OzWkg zVy*&;5&t|oYDwt$%g?{A&lzX>HgWPg%GN7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