EasemobChatGroups { public static ObjectNode createChatGroups(ObjectNode dataObjectNode) { ObjectNode objectNode = factory.objectNode(); if (!JerseyUtils.match("^(?!-)[0-9a-zA-Z\\-]+#[0-9a-zA-Z]+", APPKEY)) { LOGGER.error("Bad format of Appkey: " + APPKEY); objectNode.put("message", "Bad format of Appkey"); return objectNode; } if (!dataObjectNode.has("groupname")) { LOGGER.error("Property that named groupname must be provided ."); objectNode.put("message", "Property that named groupname must be provided ."); return objectNode; } if (!dataObjectNode.has("desc")) { LOGGER.error("Property that named desc must be provided ."); objectNode.put("message", "Property that named desc must be provided ."); return objectNode; } if (!dataObjectNode.has("public")) { LOGGER.error("Property that named public must be provided ."); objectNode.put("message", "Property that named public must be provided ."); return objectNode; } if (!dataObjectNode.has("approval")) { LOGGER.error("Property that named approval must be provided ."); objectNode.put("message", "Property that named approval must be provided ."); return objectNode; } if (!dataObjectNode.has("owner")) { LOGGER.error("Property that named owner must be provided ."); objectNode.put("message", "Property that named owner must be provided ."); return objectNode; } if (!dataObjectNode.has("members") || !dataObjectNode.path("members").isArray()) { LOGGER.error("Property that named members must be provided ."); objectNode.put("message", "Property that named members must be provided ."); return objectNode; } try { JerseyWebTarget webTarget = null; webTarget = EndPoints.CHATGROUPS_TARGET.resolveTemplate("org_name", APPKEY.split("#")[0]) .resolveTemplate("app_name", APPKEY.split("#")[1]); objectNode = JerseyUtils.sendRequest(webTarget, dataObjectNode, credential, HTTPMethod.METHOD_POST, null); } catch (Exception e) { e.printStackTrace(); } return objectNode; }  static ObjectNode getAllChatgroupids(); static ObjectNode getGroupDetailsByChatgroupid(String[] chatgroupIDs); static ObjectNode createChatGroups(ObjectNode dataObjectNode); static ObjectNode deleteChatGroups(String chatgroupid); static ObjectNode getAllMemberssByGroupId(String chatgroupid); static ObjectNode addUserToGroup(String chatgroupid, String userprimarykey); static ObjectNode deleteUserFromGroup(String chatgroupid, String userprimarykey); static ObjectNode getJoinedChatgroupsForIMUser(String username); static ObjectNode addUsersToGroupBatch(String toAddBacthChatgroupid, ObjectNode usernames);  }
@Test public void testCreatChatGroups() throws Exception { ObjectNode dataObjectNode = JsonNodeFactory.instance.objectNode(); dataObjectNode.put("groupname", "测试群组"); dataObjectNode.put("desc", "测试群组"); dataObjectNode.put("approval", true); dataObjectNode.put("public", true); dataObjectNode.put("maxusers", 333); dataObjectNode.put("owner", "101"); ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode(); arrayNode.add("101"); dataObjectNode.put("members", arrayNode); ObjectNode creatChatGroupNode = EasemobChatGroups.createChatGroups(dataObjectNode); System.out.println(creatChatGroupNode.toString()); }