@Test public void test() { String json = p.getProperty("m.init"); WechatMessage msg = (WechatMessage) handler.handle(json); assertEquals(WechatMessage.MSGTYPE_STATUSNOTIFY, msg.MsgType); System.out.println(msg.getText()); assertEquals("@b07a26ddbe1bc6a60c2d6f5cbe4c8581", msg.FromUserName); json = p.getProperty("m.g.me"); msg = (WechatMessage) handler.handle(json); gmInterceptor.handle(msg); assertEquals(WechatMessage.MSGTYPE_TEXT, msg.MsgType); System.out.println(msg.getText()); assertEquals("my msg", msg.getText()); assertEquals("@857308baac029b0748006b3432db8444", msg.FromUserName); assertTrue(msg.groupId.startsWith("@@")); json = p.getProperty("m.g.you"); msg = (WechatMessage) handler.handle(json); gmInterceptor.handle(msg); assertEquals(WechatMessage.MSGTYPE_TEXT, msg.MsgType); System.out.println(msg.getText()); assertEquals("other msg", msg.getText()); assertEquals("@88dcb5228fb45890df826b95671e770c", msg.src); assertTrue(msg.groupId.startsWith("@@")); }
@Override public WechatMessage handle(JsonObject result) { WechatMessage msg = gson.fromJson(result, WechatMessage.class); msg.setRaw(result.toString()); return msg; }
WechatMessageHandler implements MessageHandler<WechatMessage> { @Override public WechatMessage handle(JsonObject result) { WechatMessage msg = gson.fromJson(result, WechatMessage.class); msg.setRaw(result.toString()); return msg; } }
WechatMessageHandler implements MessageHandler<WechatMessage> { @Override public WechatMessage handle(JsonObject result) { WechatMessage msg = gson.fromJson(result, WechatMessage.class); msg.setRaw(result.toString()); return msg; }  }
WechatMessageHandler implements MessageHandler<WechatMessage> { @Override public WechatMessage handle(JsonObject result) { WechatMessage msg = gson.fromJson(result, WechatMessage.class); msg.setRaw(result.toString()); return msg; }  @Override WechatMessage handle(JsonObject result); @Override WechatMessage handle(String json); List<WechatMessage> handleAll(JsonObject dic); }
WechatMessageHandler implements MessageHandler<WechatMessage> { @Override public WechatMessage handle(JsonObject result) { WechatMessage msg = gson.fromJson(result, WechatMessage.class); msg.setRaw(result.toString()); return msg; }  @Override WechatMessage handle(JsonObject result); @Override WechatMessage handle(String json); List<WechatMessage> handleAll(JsonObject dic);  }