From fcb762a10e06ae9bb9b23cff0d2745b849ea972a Mon Sep 17 00:00:00 2001 From: Rime <81419447+Emirlol@users.noreply.github.com> Date: Sat, 8 Mar 2025 07:56:42 +0300 Subject: Fix empty validLocations set failing to be decoded (#1197) * Fix empty `validLocations` set failing to be decoded * Remove unnecessary override * Add encode tests --------- Co-authored-by: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> --- .../skyblocker/skyblock/chat/ChatRuleTest.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java b/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java index 1c5004fc..21831918 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java @@ -70,4 +70,28 @@ class ChatRuleTest { )).getOrThrow() ); } + + @Test + void codecParseEmptySet() { + Assertions.assertEquals( + EnumSet.noneOf(Location.class), + ChatRule.LOCATION_FIXING_CODEC.parse(JsonOps.INSTANCE, JsonOps.INSTANCE.createList(Stream.empty())).getOrThrow() + ); + } + + @Test + void codecEncode() { + Assertions.assertEquals( + JsonOps.INSTANCE.createList(Stream.empty()), + ChatRule.LOCATION_FIXING_CODEC.encodeStart(JsonOps.INSTANCE, EnumSet.noneOf(Location.class)).getOrThrow() + ); + + Assertions.assertEquals( + JsonOps.INSTANCE.createList(Stream.of(Location.DWARVEN_MINES, Location.WINTER_ISLAND) + .map(Location::asString) + .map(JsonOps.INSTANCE::createString) + ), + ChatRule.LOCATION_FIXING_CODEC.encodeStart(JsonOps.INSTANCE, EnumSet.of(Location.DWARVEN_MINES, Location.WINTER_ISLAND)).getOrThrow() + ); + } } -- cgit