feat: 反序列化
This commit is contained in:
@@ -5,6 +5,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class UserAccountStatusEnumTest extends BaseTest {
|
||||
@@ -18,7 +20,17 @@ public class UserAccountStatusEnumTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void toJson() throws JsonProcessingException {
|
||||
// 序列化
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
assertEquals("{\"code\":0,\"desc\":\"正常\"}", objectMapper.writeValueAsString(UserAccountStatusEnum.NORMAL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() throws IOException {
|
||||
// 反序列化
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
UserAccountStatusEnum userAccountStatusEnum = mapper.readValue(mapper.writeValueAsString(UserAccountStatusEnum.NORMAL), UserAccountStatusEnum.class);
|
||||
assertEquals(UserAccountStatusEnum.NORMAL.getCode(), userAccountStatusEnum.getCode());
|
||||
assertEquals(UserAccountStatusEnum.NORMAL.getDesc(), userAccountStatusEnum.getDesc());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user