1
0
mirror of synced 2026-10-12 10:06:42 +08:00

🎨 完善 NFC 小程序 scheme 接口测试代码

This commit is contained in:
Binary Wang
2026-06-12 15:00:31 +08:00
committed by GitHub
parent 85f728d81d
commit 24d20b319e
4 changed files with 36 additions and 3 deletions

View File

@@ -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 生成失败时抛出,具体错误码请看文档
*/

View File

@@ -42,7 +42,7 @@ public class WxMaSchemeServiceImpl implements WxMaSchemeService {
/**
* 获取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 生成失败时抛出,具体错误码请看文档

View File

@@ -66,7 +66,7 @@ public class WxMaEmployeeRelationServiceImplTest {
@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);
}

View File

@@ -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());
}
}