aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/me/xmrvizzy/skyblocker
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-08-14 00:27:23 +0800
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-08-14 16:35:18 +0800
commit99b3c44e2b6632caf14e1c95d970cd499cb57993 (patch)
treef8446638f451185abffd2c97d524c73edb1955d0 /src/test/java/me/xmrvizzy/skyblocker
parentcfe75f10c006a09b5844739ffcae00ab99992412 (diff)
downloadSkyblocker-99b3c44e2b6632caf14e1c95d970cd499cb57993.tar.gz
Skyblocker-99b3c44e2b6632caf14e1c95d970cd499cb57993.tar.bz2
Skyblocker-99b3c44e2b6632caf14e1c95d970cd499cb57993.zip
De-hardcode armor trim types
Diffstat (limited to 'src/test/java/me/xmrvizzy/skyblocker')
-rw-r--r--src/test/java/me/xmrvizzy/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/java/me/xmrvizzy/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java b/src/test/java/me/xmrvizzy/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java
new file mode 100644
index 00000000..a6ef79b0
--- /dev/null
+++ b/src/test/java/me/xmrvizzy/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java
@@ -0,0 +1,27 @@
+package me.xmrvizzy.skyblocker.skyblock.item;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import net.minecraft.util.Identifier;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class ArmorTrimIdSerializationTest {
+ private final Gson gson = new GsonBuilder().registerTypeAdapter(Identifier.class, new Identifier.Serializer()).create();
+
+ @Test
+ void serialize() {
+ CustomArmorTrims.ArmorTrimId armorTrimId = new CustomArmorTrims.ArmorTrimId(new Identifier("material_id"), new Identifier("pattern_id"));
+ String json = gson.toJson(armorTrimId);
+ String expectedJson = "{\"material\":\"minecraft:material_id\",\"pattern\":\"minecraft:pattern_id\"}";
+ Assertions.assertEquals(expectedJson, json);
+ }
+
+ @Test
+ void deserialize() {
+ String json = "{\"material\":\"minecraft:material_id\",\"pattern\":\"minecraft:pattern_id\"}";
+ CustomArmorTrims.ArmorTrimId armorTrimId = gson.fromJson(json, CustomArmorTrims.ArmorTrimId.class);
+ CustomArmorTrims.ArmorTrimId expectedArmorTrimId = new CustomArmorTrims.ArmorTrimId(new Identifier("material_id"), new Identifier("pattern_id"));
+ Assertions.assertEquals(expectedArmorTrimId, armorTrimId);
+ }
+}