ImUtils { public static String createGroup(String groupName, String groupDesc, Boolean retry) throws ImException { ObjectNode dataObjectNode = JsonNodeFactory.instance.objectNode(); dataObjectNode.put("groupname", groupName); dataObjectNode.put("desc", groupDesc); dataObjectNode.put("approval", true); dataObjectNode.put("public", false); dataObjectNode.put("maxusers", 200); dataObjectNode.put("owner", SYSTEM_USER_ID); ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode(); dataObjectNode.put("members", arrayNode); ObjectNode createChatGroupNode; try { createChatGroupNode = EasemobChatGroups.createChatGroups(dataObjectNode); checkResult(createChatGroupNode); } catch (ImException e) { if (retry) { createChatGroupNode = EasemobChatGroups.createChatGroups(dataObjectNode); checkResult(createChatGroupNode); } else { throw e; } } return createChatGroupNode.get("data").get("groupid").asText(); }  static void createUser(String userId, String userToken, String nickName); static void addUserToGroup(String groupId, String userId); static String createGroup(String groupName, String groupDesc, Boolean retry); static String createGroup(); static void setUserPassword(String userId, String newPassword); static final String SYSTEM_USER_ID; }
@Test public void testCreateGroup() throws Exception { String userId = String.valueOf(new Date().getTime()); String userId2 = userId + "2"; ImUtils.createUser(userId, "token", "小灰灰"); ImUtils.createUser(userId2, "token", "小灰灰2"); String groupId = ImUtils.createGroup(); ImUtils.addUserToGroup(groupId, userId2); }