FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

修复 WxMaMediaAsyncCheckResult 缺少 result 和 detail 字段 by Copilot · Pull Request #3882 · binarywang/WxJava · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;

import java.io.Serializable;
import java.util.List;

/**
* @author borisbao
Expand All @@ -26,6 +27,18 @@ public class WxMaMediaAsyncCheckResult implements Serializable {
/**
* 综合结果
*/
@SerializedName("result")
private ResultBean result;

/**
* 详细检测结果列表
*/
@SerializedName("detail")
private List<DetailBean> detail;

/**
* 综合结果内部类定义
*/
@Data
@Builder
@XStreamAlias("result")
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package cn.binarywang.wx.miniapp.bean;

import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;

/**
* 测试多媒体内容安全异步检测结果解析
*
* @author copilot
*/
@Test
public class WxMaMediaAsyncCheckResultTest {

public void testFromJsonWithResultAndDetail() {
String json = "{\n"
+ " \"trace_id\": \"test_trace_id_001\",\n"
+ " \"result\": {\n"
+ " \"suggest\": \"risky\",\n"
+ " \"label\": 20001\n"
+ " },\n"
+ " \"detail\": [\n"
+ " {\n"
+ " \"strategy\": \"content_model\",\n"
+ " \"errcode\": 0,\n"
+ " \"suggest\": \"risky\",\n"
+ " \"label\": 20006,\n"
+ " \"prob\": 90\n"
+ " }\n"
+ " ]\n"
+ "}";

WxMaMediaAsyncCheckResult result = WxMaMediaAsyncCheckResult.fromJson(json);

assertNotNull(result);
assertEquals(result.getTraceId(), "test_trace_id_001");

assertNotNull(result.getResult());
assertEquals(result.getResult().getSuggest(), "risky");
assertEquals(result.getResult().getLabel(), "20001");

assertNotNull(result.getDetail());
assertEquals(result.getDetail().size(), 1);
WxMaMediaAsyncCheckResult.DetailBean detail = result.getDetail().get(0);
assertEquals(detail.getStrategy(), "content_model");
assertEquals(detail.getErrcode(), Integer.valueOf(0));
assertEquals(detail.getSuggest(), "risky");
assertEquals(detail.getLabel(), "20006");
assertEquals(detail.getProb(), Integer.valueOf(90));
}
}

Back | FazBrowse Home | New Git URL