Skip to content

Commit

Permalink
add testcase for issue #605
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Aug 3, 2022
1 parent 69b2c46 commit fd2dc77
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions core/src/test/java/com/alibaba/fastjson2/issues/Issue605.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.alibaba.fastjson2.issues;

import com.alibaba.fastjson2.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Issue605 {
@Test
public void test() {
WinningInformationBo bo = new WinningInformationBo();
bo.isSuccess = true;
bo.wxId = "abc";
bo.parems = new HashMap<>();

String str = JSON.toJSONString(bo);
assertEquals("{\"parems\":{},\"success\":true,\"wxId\":\"abc\"}", str);

WinningInformationBo bo1 = JSON.parseObject(str, WinningInformationBo.class);
assertEquals(bo.wxId, bo1.wxId);
assertEquals(bo.isSuccess, bo1.isSuccess);
assertEquals(bo.parems, bo1.parems);
}

@Setter
@Getter
@Accessors(chain = true)
public static class WinningInformationBo{
private boolean isSuccess;
private String wxId;
private Map<String, String> parems;
}
}

0 comments on commit fd2dc77

Please sign in to comment.