diff options
author | msg-programs <msgdoesstuff@gmail.com> | 2023-08-20 13:22:34 +0200 |
---|---|---|
committer | msg-programs <msgdoesstuff@gmail.com> | 2023-08-20 13:22:34 +0200 |
commit | e228eac03fbe10ea3ffd1c2e1930f33318a98c70 (patch) | |
tree | dd62c5462f865e919160a8fbb01129cf608b9f1c /src/test/java/me/xmrvizzy/skyblocker/skyblock | |
parent | bb2612feb2b86e94d23d02fbc3e66d5abeb6dd41 (diff) | |
parent | 6069d3cf7d2e96ca7ef1975a3dd04e2121a6e3c9 (diff) | |
download | Skyblocker-e228eac03fbe10ea3ffd1c2e1930f33318a98c70.tar.gz Skyblocker-e228eac03fbe10ea3ffd1c2e1930f33318a98c70.tar.bz2 Skyblocker-e228eac03fbe10ea3ffd1c2e1930f33318a98c70.zip |
Merge branch 'master' of https://github.com/SkyblockerMod/Skyblocker into json-tabhud
Pull newest changes from upstream
Diffstat (limited to 'src/test/java/me/xmrvizzy/skyblocker/skyblock')
-rw-r--r-- | src/test/java/me/xmrvizzy/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java | 27 |
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); + } +} |