1 package com.foxinmy.weixin4j.wxa.api;
2
3 import static org.junit.Assert.assertTrue;
4
5 import org.junit.Test;
6
7 import com.alibaba.fastjson.JSON;
8 import com.foxinmy.weixin4j.wxa.model.custommessage.CustomMessage;
9 import com.foxinmy.weixin4j.wxa.model.custommessage.Text;
10
11 public class CustomMessageAdaptersTest {
12
13 @Test
14 public void testToMap() {
15 CustomMessage customMessage = new CustomMessage();
16 customMessage.setToUser("OPENID");
17 customMessage.setTuple(new Text("Hello World"));
18
19 String json = JSON.toJSONString(CustomMessageAdapters.toMap(customMessage));
20 assertTrue(json.contains("\"touser\":\"OPENID\""));
21 assertTrue(json.contains("\"msgtype\":\"text\""));
22 assertTrue(json.contains("\"text\":{\"content\":\"Hello World\"}"));
23 }
24
25 }