Implement WXA custom message related APIs.

This commit is contained in:
Sutra Zhou
2018-05-29 03:18:03 +08:00
parent 0566d8e290
commit 9f60273e21
13 changed files with 431 additions and 0 deletions
@@ -0,0 +1,24 @@
package com.foxinmy.weixin4j.wxa.api;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.alibaba.fastjson.JSON;
import com.foxinmy.weixin4j.wxa.model.custommessage.CustomMessage;
import com.foxinmy.weixin4j.wxa.model.custommessage.Text;
public class CustomMessageAdaptersTest {
@Test
public void testToMap() {
CustomMessage customMessage = new CustomMessage();
customMessage.setToUser("OPENID");
customMessage.setTuple(new Text("Hello World"));
String json = JSON.toJSONString(CustomMessageAdapters.toMap(customMessage));
System.out.println(json);
assertEquals("{\"touser\":\"OPENID\",\"text\":{\"content\":\"Hello World\"},\"msgtype\":\"text\"}", json);
}
}
@@ -0,0 +1,15 @@
package com.foxinmy.weixin4j.wxa.model.custommessage;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class CommandTest {
@Test
public void testToString() {
assertEquals("Typing", Command.TYPING.toString());
assertEquals("CancelTyping", Command.CANCEL_TYPING.toString());
}
}