-
-
Notifications
You must be signed in to change notification settings - Fork 9k
🎨 #3808 【小程序】重构微信小程序用工关系文档地址,请求实体,增加单元测试 #3867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
73 changes: 73 additions & 0 deletions
73
.../src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaEmployeeRelationServiceImplTest.java
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,73 @@ | ||
| package cn.binarywang.wx.miniapp.api.impl; | ||
|
|
||
| import cn.binarywang.wx.miniapp.api.WxMaService; | ||
| import cn.binarywang.wx.miniapp.bean.employee.WxMaSendEmployeeMsgRequest; | ||
| import cn.binarywang.wx.miniapp.bean.employee.WxMaUnbindEmployeeRequest; | ||
| import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; | ||
| import cn.binarywang.wx.miniapp.test.ApiTestModule; | ||
| import com.google.inject.Inject; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import me.chanjar.weixin.common.error.WxErrorException; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.testng.annotations.Guice; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| @Slf4j | ||
| @Test | ||
| @Guice(modules = ApiTestModule.class) | ||
| public class WxMaEmployeeRelationServiceImplTest { | ||
|
|
||
| @Inject | ||
| protected WxMaService wxService; | ||
|
|
||
| @Test | ||
| public void testSendEmployeeMsg() throws WxErrorException { | ||
| WxMaSendEmployeeMsgRequest wxMaSendEmployeeMsgRequest = new WxMaSendEmployeeMsgRequest(); | ||
| wxMaSendEmployeeMsgRequest.setPage("/pages/index/index"); | ||
| wxMaSendEmployeeMsgRequest.setTouser("o0uBr12b1zdgCk1qDoBivmSYb9GA"); | ||
| wxMaSendEmployeeMsgRequest.setTemplateId("nmO-O4V33TOREVLAlumwPCsHssqkt7mea_cyWNE-IFmZqT9jh_LsERhzDOsOqa-3"); | ||
|
|
||
| // 使用 HashMap 构建数据结构 | ||
| Map<String, Object> data1 = new HashMap<>(); | ||
| // 内层字段 | ||
| Map<String, Object> dataContent = getStringObjectMap(); | ||
|
|
||
| data1.put("data", dataContent); | ||
| wxMaSendEmployeeMsgRequest.setData(WxMaGsonBuilder.create().toJson(data1)); | ||
| this.wxService.getEmployeeRelationService().sendEmployeeMsg(wxMaSendEmployeeMsgRequest); | ||
| } | ||
|
|
||
| @NotNull | ||
| private static Map<String, Object> getStringObjectMap() { | ||
| Map<String, String> thing1 = new HashMap<>(); | ||
| Map<String, String> thing2 = new HashMap<>(); | ||
| Map<String, String> time1 = new HashMap<>(); | ||
| Map<String, String> character_string1 = new HashMap<>(); | ||
| Map<String, String> time2 = new HashMap<>(); | ||
| thing1.put("value", "高和蓝枫箱体测试"); | ||
| thing2.put("value", "门口全英测试"); | ||
| time1.put("value", "2026年11月23日 19:19"); | ||
| character_string1.put("value", "50kg"); | ||
| time2.put("value", "2026年11月23日 19:19"); | ||
|
|
||
| // 模板消息变量,有顺序要求 | ||
| Map<String, Object> dataContent = new LinkedHashMap<>(); | ||
| dataContent.put("thing1", thing1); | ||
| dataContent.put("thing2", thing2); | ||
| dataContent.put("time1", time1); | ||
| dataContent.put("character_string1", character_string1); | ||
| dataContent.put("time2", time2); | ||
| return dataContent; | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| public void testUnbinduserb2cauthinfo() throws WxErrorException { | ||
| WxMaUnbindEmployeeRequest wxMaUnbindEmployeeRequest = new WxMaUnbindEmployeeRequest(); | ||
| wxMaUnbindEmployeeRequest.setOpenidList(List.of("o0uBr12b1zdgCk1qDoBivmSYb9GA")); | ||
| this.wxService.getEmployeeRelationService().unbindEmployee(wxMaUnbindEmployeeRequest); | ||
| } | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testSendEmployeeMsg/testUnbinduserb2cauthinfohardcodeopenid/templateIdvalues that look environment-specific (and potentially sensitive). Consider sourcing these fromTestConfiglike other miniapp API tests so the test is portable across environments.Other Locations
weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaEmployeeRelationServiceImplTest.java:34weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaEmployeeRelationServiceImplTest.java:73🤖 Was this useful? React with 👍 or 👎