@Test public void testToMap() { CustomMessage customMessage = new CustomMessage(); customMessage.setToUser("OPENID"); customMessage.setTuple(new Text("Hello World")); String json = JSON.toJSONString(CustomMessageAdapters.toMap(customMessage)); assertTrue(json.contains("\"touser\":\"OPENID\"")); assertTrue(json.contains("\"msgtype\":\"text\"")); assertTrue(json.contains("\"text\":{\"content\":\"Hello World\"}")); }
public static Map<String, Object> toMap(CustomMessage customMessage) { final NotifyTuple tuple = customMessage.getTuple(); final String msgType = tuple.getMessageType(); final Map<String, Object> params = new HashMap<String, Object>(3); params.put("touser", customMessage.getToUser()); params.put("msgtype", msgType); params.put(msgType, tuple); return params; }
CustomMessageAdapters { public static Map<String, Object> toMap(CustomMessage customMessage) { final NotifyTuple tuple = customMessage.getTuple(); final String msgType = tuple.getMessageType(); final Map<String, Object> params = new HashMap<String, Object>(3); params.put("touser", customMessage.getToUser()); params.put("msgtype", msgType); params.put(msgType, tuple); return params; } }
CustomMessageAdapters { public static Map<String, Object> toMap(CustomMessage customMessage) { final NotifyTuple tuple = customMessage.getTuple(); final String msgType = tuple.getMessageType(); final Map<String, Object> params = new HashMap<String, Object>(3); params.put("touser", customMessage.getToUser()); params.put("msgtype", msgType); params.put(msgType, tuple); return params; } private  CustomMessageAdapters(); }
CustomMessageAdapters { public static Map<String, Object> toMap(CustomMessage customMessage) { final NotifyTuple tuple = customMessage.getTuple(); final String msgType = tuple.getMessageType(); final Map<String, Object> params = new HashMap<String, Object>(3); params.put("touser", customMessage.getToUser()); params.put("msgtype", msgType); params.put(msgType, tuple); return params; } private  CustomMessageAdapters(); static Map<String, Object> toMap(CustomMessage customMessage); static Map<String, String> toMap(String toUser, Command command); }
CustomMessageAdapters { public static Map<String, Object> toMap(CustomMessage customMessage) { final NotifyTuple tuple = customMessage.getTuple(); final String msgType = tuple.getMessageType(); final Map<String, Object> params = new HashMap<String, Object>(3); params.put("touser", customMessage.getToUser()); params.put("msgtype", msgType); params.put(msgType, tuple); return params; } private  CustomMessageAdapters(); static Map<String, Object> toMap(CustomMessage customMessage); static Map<String, String> toMap(String toUser, Command command);  }