From 0d0237488e15469432c17627db65a0ad6c188563 Mon Sep 17 00:00:00 2001 From: Looly Date: Wed, 4 Sep 2024 20:53:25 +0800 Subject: [PATCH] add test --- .../dromara/hutool/json/IssueIAOPI9Test.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 hutool-json/src/test/java/org/dromara/hutool/json/IssueIAOPI9Test.java diff --git a/hutool-json/src/test/java/org/dromara/hutool/json/IssueIAOPI9Test.java b/hutool-json/src/test/java/org/dromara/hutool/json/IssueIAOPI9Test.java new file mode 100644 index 000000000..784e02db1 --- /dev/null +++ b/hutool-json/src/test/java/org/dromara/hutool/json/IssueIAOPI9Test.java @@ -0,0 +1,44 @@ +package org.dromara.hutool.json; + +import lombok.Data; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class IssueIAOPI9Test { + @Test + void toBeanTest() { + final String jsonStr = "{\"chatCommandType\":\"CHAT_MSG\"}"; + final ChatPublicAppReceiveMq mqChatRequest = JSONUtil.toBean(jsonStr, ChatPublicAppReceiveMq.class); + Assertions.assertEquals("CHAT_MSG", mqChatRequest.getChatCommandType().name()); + } + + @Data + static class ChatPublicAppReceiveMq { + private ChatAppMqCommandTypeEnum chatCommandType; + } + + public enum ChatAppMqCommandTypeEnum { + /** + * 对话消息 + */ + CHAT_MSG("chat_msg"), + + /** + * 对话消息(批量-群发) + */ + CHAT_MSG_BATCH("chat_msg_batch"), + /** + * 命令消息 + */ + COMMAND_MSG("command_msg") + ; + ChatAppMqCommandTypeEnum(final String type) { + this.type = type; + } + + private final String type; + public String getType() { + return type; + } + } +}