Skip to content

Commit e343159

Browse files
committed
🎨 修复测试代码
1 parent 7b4ba55 commit e343159

File tree

7 files changed

+10
-8
lines changed

7 files changed

+10
-8
lines changed

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/DataUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.chanjar.weixin.common.util;
22

3+
import org.apache.commons.lang3.RegExUtils;
34
import org.apache.commons.lang3.StringUtils;
45

56
/**
@@ -17,7 +18,7 @@ public class DataUtils {
1718
public static <E> E handleDataWithSecret(E data) {
1819
E dataForLog = data;
1920
if(data instanceof String && StringUtils.contains((String)data, "&secret=")){
20-
dataForLog = (E) StringUtils.replaceAll((String)data,"&secret=\\w+&","&secret=******&");
21+
dataForLog = (E) RegExUtils.replaceAll((String)data,"&secret=\\w+&","&secret=******&");
2122
}
2223
return dataForLog;
2324
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/xml/XStreamInitializer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ protected void setupConverters() {
8080
};
8181
xstream.ignoreUnknownElements();
8282
xstream.setMode(XStream.NO_REFERENCES);
83-
XStream.setupDefaultSecurity(xstream);
8483
xstream.autodetectAnnotations(true);
8584

8685
// setup proper security by limiting which classes can be loaded by XStream

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public WxCpConfigStorage getWxCpConfigStorage() {
9292
RequestExecutor<Object, Object> re = mock(RequestExecutor.class);
9393

9494
AtomicInteger counter = new AtomicInteger();
95-
Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer((InvocationOnMock invocation) -> {
95+
Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer(invocation -> {
9696
counter.incrementAndGet();
9797
WxError error = WxError.builder().errorCode(WxMpErrorMsgEnum.CODE_40001.getCode()).errorMsg(WxMpErrorMsgEnum.CODE_40001.getMsg()).build();
9898
throw new WxErrorException(error);

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ private static void initWeixin() throws IOException {
4949
wxCpService = new WxCpServiceImpl();
5050
wxCpService.setWxCpConfigStorage(config);
5151

52-
WxCpMessageHandler handler = (WxCpXmlMessage wxMessage, Map context, WxCpService wxService, WxSessionManager sessionManager) -> {
52+
WxCpMessageHandler handler = (wxMessage, context, wxService, sessionManager) -> {
5353
WxCpXmlOutTextMessage m = WxCpXmlOutMessage.TEXT().content("测试加密消息")
5454
.fromUser(wxMessage.getToUserName())
5555
.toUser(wxMessage.getFromUserName()).build();
5656
return m;
5757
};
5858

59-
WxCpMessageHandler oauth2handler = (WxCpXmlMessage wxMessage, Map context, WxCpService wxService, WxSessionManager sessionManager) -> {
59+
WxCpMessageHandler oauth2handler = (wxMessage, context, wxService, sessionManager) -> {
6060
String href = "<a href=\""
6161
+ wxService.getOauth2Service().buildAuthorizationUrl(wxCpConfigStorage.getOauth2redirectUri(), null)
6262
+ "\">测试oauth2</a>";
@@ -78,7 +78,7 @@ private static void initWeixin() throws IOException {
7878
.end()
7979
.rule()
8080
.event(WxCpConsts.EventType.CHANGE_CONTACT)
81-
.handler((WxCpXmlMessage wxMessage, Map context, WxCpService wxCpService, WxSessionManager sessionManager) -> {
81+
.handler((wxMessage, context, wxCpService, sessionManager) -> {
8282
System.out.println("通讯录发生变更");
8383
return null;
8484
})

weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
127127
RequestExecutor<Object, Object> re = mock(RequestExecutor.class);
128128

129129
AtomicInteger counter = new AtomicInteger();
130-
Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer((InvocationOnMock invocation) -> {
130+
Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer((invocation) -> {
131131
counter.incrementAndGet();
132132
WxError error = WxError.builder().errorCode(WxMpErrorMsgEnum.CODE_40001.getCode()).errorMsg(WxMpErrorMsgEnum.CODE_40001.getMsg()).build();
133133
throw new WxErrorException(error);

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public HttpType getRequestType() {
237237
RequestExecutor<Object, Object> re = mock(RequestExecutor.class);
238238

239239
AtomicInteger counter = new AtomicInteger();
240-
Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer((InvocationOnMock invocation) -> {
240+
Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer(invocation -> {
241241
counter.incrementAndGet();
242242
WxError error = WxError.builder().errorCode(WxMpErrorMsgEnum.CODE_40001.getCode()).errorMsg(WxMpErrorMsgEnum.CODE_40001.getMsg()).build();
243243
throw new WxErrorException(error);

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxSignQueryResult.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.thoughtworks.xstream.annotations.XStreamAlias;
44
import lombok.AllArgsConstructor;
55
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
67
import lombok.NoArgsConstructor;
78
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
89
import org.w3c.dom.Document;
@@ -18,6 +19,7 @@
1819
* </pre>
1920
*/
2021
@Data
22+
@EqualsAndHashCode(callSuper = true)
2123
@AllArgsConstructor
2224
@NoArgsConstructor
2325
public class WxSignQueryResult extends BaseWxPayResult implements Serializable {

0 commit comments

Comments
 (0)