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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface WxMaSchemeService {
String generate(WxMaGenerateSchemeRequest request) throws WxErrorException;
/**
* 获取NFC 的小程序 scheme
*文档地址:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/url-scheme/generateNFCScheme.html
*文档地址:https://developers.weixin.qq.com/miniprogram/dev/server/API/qrcode-link/url-scheme/api_generatenfcscheme.html
* @param request 请求参数
* @throws WxErrorException 生成失败时抛出,具体错误码请看文档
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public String generate(WxMaGenerateSchemeRequest request) throws WxErrorExceptio

/**
* 获取NFC 的小程序 scheme
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/url-scheme/generateNFCScheme.html
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/server/API/qrcode-link/url-scheme/api_generatenfcscheme.html
*
* @param request 请求参数
* @throws WxErrorException 生成失败时抛出,具体错误码请看文档
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static Map<String, Object> getStringObjectMap() {
@Test
public void testUnbinduserb2cauthinfo() throws WxErrorException {
WxMaUnbindEmployeeRequest wxMaUnbindEmployeeRequest = new WxMaUnbindEmployeeRequest();
wxMaUnbindEmployeeRequest.setOpenidList(List.of("o0uBr12b1zdgCk1qDoBivmSYb9GA"));
wxMaUnbindEmployeeRequest.setOpenidList(Collections.singletonList("o0uBr12b1zdgCk1qDoBivmSYb9GA"));
this.wxService.getEmployeeRelationService().unbindEmployee(wxMaUnbindEmployeeRequest);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cn.binarywang.wx.miniapp.bean.scheme;

import me.chanjar.weixin.common.util.json.GsonParser;
import org.testng.annotations.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class WxMaGenerateNfcSchemeRequestTest {
@Test
public void testToJson() {
WxMaGenerateNfcSchemeRequest request = WxMaGenerateNfcSchemeRequest.newBuilder()
.jumpWxa(WxMaGenerateNfcSchemeRequest.JumpWxa.newBuilder()
.path("pages/index/index")
.query("device=demo")
.envVersion("trial")
.build())
.modelId("model-demo")
.sn("sn-demo")
.build();

String expectedJson = "{\n"
+ " \"jump_wxa\": {\n"
+ " \"path\": \"pages/index/index\",\n"
+ " \"query\": \"device=demo\",\n"
+ " \"env_version\": \"trial\"\n"
+ " },\n"
+ " \"model_id\": \"model-demo\",\n"
+ " \"sn\": \"sn-demo\"\n"
+ "}";

assertThat(request.toJson()).isEqualTo(GsonParser.parse(expectedJson).toString());

@augmentcode augmentcode Bot Jun 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里直接断言 request.toJson() 的字符串相等,会受 JSON 字段顺序影响(JSON 语义上是无序的),后续若序列化顺序变化/新增字段可能导致非预期的测试失败。建议把两边都 parse 成 JSON 结构后做语义比较,以减少脆弱性。

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

}
}