Fix CustomMessageAdapters.

This commit is contained in:
Sutra Zhou 2018-05-29 15:11:21 +08:00
parent aad62d7739
commit 138fadb68b
2 changed files with 5 additions and 4 deletions

View File

@ -24,7 +24,7 @@ final class CustomMessageAdapters {
final Map<String, Object> params = new HashMap<String, Object>(3); final Map<String, Object> params = new HashMap<String, Object>(3);
params.put("touser", customMessage.getToUser()); params.put("touser", customMessage.getToUser());
params.put("msgtype", msgType); params.put("msgtype", msgType);
params.put(msgType, customMessage.getTuple()); params.put(msgType, tuple);
return params; return params;
} }

View File

@ -1,6 +1,6 @@
package com.foxinmy.weixin4j.wxa.api; package com.foxinmy.weixin4j.wxa.api;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
@ -17,8 +17,9 @@ public class CustomMessageAdaptersTest {
customMessage.setTuple(new Text("Hello World")); customMessage.setTuple(new Text("Hello World"));
String json = JSON.toJSONString(CustomMessageAdapters.toMap(customMessage)); String json = JSON.toJSONString(CustomMessageAdapters.toMap(customMessage));
System.out.println(json); assertTrue(json.contains("\"touser\":\"OPENID\""));
assertEquals("{\"touser\":\"OPENID\",\"text\":{\"content\":\"Hello World\"},\"msgtype\":\"text\"}", json); assertTrue(json.contains("\"msgtype\":\"text\""));
assertTrue(json.contains("\"text\":{\"content\":\"Hello World\"}"));
} }
} }