From 0a3ddbabb1af572aecf32feebfe47e38a462d273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=82=85=E4=B8=9C=E6=B5=B7?= <296322762@qq.com> Date: Wed, 20 Nov 2024 13:55:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=B9=E9=87=8F=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=BE=A4=E6=88=90=E5=91=98=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/easemob/im/api/MetadataApi.java | 113 +++++++++ .../EMBatchCustomGroupMemberAttribute.java | 216 ++++++++++++++++++ ...BatchCustomGroupMemberAttributeResult.java | 185 +++++++++++++++ .../com/easemob/im/api/MetadataApiTest.java | 80 +++++++ 4 files changed, 594 insertions(+) create mode 100644 src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttribute.java create mode 100644 src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttributeResult.java diff --git a/src/main/java/com/easemob/im/api/MetadataApi.java b/src/main/java/com/easemob/im/api/MetadataApi.java index 32ad5b924..a8f278c60 100644 --- a/src/main/java/com/easemob/im/api/MetadataApi.java +++ b/src/main/java/com/easemob/im/api/MetadataApi.java @@ -66,6 +66,119 @@ public void setCustomBaseUrl(String customBaseUrl) { this.localCustomBaseUrl = customBaseUrl; } + /** + * Build call for batchCustomGroupMemberAttribute + * @param groupId (required) + * @param emBatchCustomGroupMemberAttribute (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * http.response.details + */ + public okhttp3.Call batchCustomGroupMemberAttributeCall(String groupId, List emBatchCustomGroupMemberAttribute, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = emBatchCustomGroupMemberAttribute; + + // create path and map variables + String localVarPath = "/metadata/chatgroup/{group_id}/users/batch" + .replace("{" + "group_id" + "}", localVarApiClient.escapeString(groupId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call batchCustomGroupMemberAttributeValidateBeforeCall(String groupId, List emBatchCustomGroupMemberAttribute, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException("Missing the required parameter 'groupId' when calling batchCustomGroupMemberAttribute(Async)"); + } + + return batchCustomGroupMemberAttributeCall(groupId, emBatchCustomGroupMemberAttribute, _callback); + + } + + /** + * 批量设置群成员自定义属性 + * 批量设置群成员的自定义属性(key-value),例如,在群组中的昵称和头像等。每次请求最多可为 20 个群成员设置多个属性,而且可对不同群成员设置不同属性。传入相同用户 ID 时,若其属性名称不同,则添加,相同则更新。文档介绍:https://doc.easemob.com/document/server-side/group_member.html#%E6%89%B9%E9%87%8F%E8%AE%BE%E7%BD%AE%E7%BE%A4%E6%88%90%E5%91%98%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param emBatchCustomGroupMemberAttribute (optional) + * @return EMBatchCustomGroupMemberAttributeResult + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * http.response.details + */ + public EMBatchCustomGroupMemberAttributeResult batchCustomGroupMemberAttribute(String groupId, List emBatchCustomGroupMemberAttribute) throws ApiException { + ApiResponse localVarResp = batchCustomGroupMemberAttributeWithHttpInfo(groupId, emBatchCustomGroupMemberAttribute); + return localVarResp.getData(); + } + + /** + * 批量设置群成员自定义属性 + * 批量设置群成员的自定义属性(key-value),例如,在群组中的昵称和头像等。每次请求最多可为 20 个群成员设置多个属性,而且可对不同群成员设置不同属性。传入相同用户 ID 时,若其属性名称不同,则添加,相同则更新。文档介绍:https://doc.easemob.com/document/server-side/group_member.html#%E6%89%B9%E9%87%8F%E8%AE%BE%E7%BD%AE%E7%BE%A4%E6%88%90%E5%91%98%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param emBatchCustomGroupMemberAttribute (optional) + * @return ApiResponse<EMBatchCustomGroupMemberAttributeResult> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * http.response.details + */ + public ApiResponse batchCustomGroupMemberAttributeWithHttpInfo(String groupId, List emBatchCustomGroupMemberAttribute) throws ApiException { + okhttp3.Call localVarCall = batchCustomGroupMemberAttributeValidateBeforeCall(groupId, emBatchCustomGroupMemberAttribute, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * 批量设置群成员自定义属性 (asynchronously) + * 批量设置群成员的自定义属性(key-value),例如,在群组中的昵称和头像等。每次请求最多可为 20 个群成员设置多个属性,而且可对不同群成员设置不同属性。传入相同用户 ID 时,若其属性名称不同,则添加,相同则更新。文档介绍:https://doc.easemob.com/document/server-side/group_member.html#%E6%89%B9%E9%87%8F%E8%AE%BE%E7%BD%AE%E7%BE%A4%E6%88%90%E5%91%98%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * @param groupId (required) + * @param emBatchCustomGroupMemberAttribute (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * http.response.details + */ + public okhttp3.Call batchCustomGroupMemberAttributeAsync(String groupId, List emBatchCustomGroupMemberAttribute, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = batchCustomGroupMemberAttributeValidateBeforeCall(groupId, emBatchCustomGroupMemberAttribute, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** * Build call for customGroupMemberAttribute * @param groupId (required) diff --git a/src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttribute.java b/src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttribute.java new file mode 100644 index 000000000..0fbdced47 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttribute.java @@ -0,0 +1,216 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import com.easemob.im.JSON; +import com.google.gson.*; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * EMBatchCustomGroupMemberAttribute + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-11-20T11:16:55.650302+08:00[Asia/Shanghai]") +public class EMBatchCustomGroupMemberAttribute { + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private Object metadata; + + public EMBatchCustomGroupMemberAttribute() { + } + + public EMBatchCustomGroupMemberAttribute username(String username) { + + this.username = username; + return this; + } + + /** + * 用户 ID,长度不可超过 64 字节 + * @return username + **/ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public EMBatchCustomGroupMemberAttribute metadata(Object metadata) { + + this.metadata = metadata; + return this; + } + + /** + * 要设置的群成员自定义属性,为 key-value 键值对。对于单个键值对: - key 表示属性名称,不能超过 16 字节。 - value 表示属性值,不能超过 512 个字节。若 value 设置为空字符串即删除该自定义属性。 单个群成员的自定义属性总长度不能超过 4 KB + * @return metadata + **/ + @javax.annotation.Nullable + public Object getMetadata() { + return metadata; + } + + + public void setMetadata(Object metadata) { + this.metadata = metadata; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMBatchCustomGroupMemberAttribute batchCustomGroupMemberAttribute = (EMBatchCustomGroupMemberAttribute) o; + return Objects.equals(this.username, batchCustomGroupMemberAttribute.username) && + Objects.equals(this.metadata, batchCustomGroupMemberAttribute.metadata); + } + + @Override + public int hashCode() { + return Objects.hash(username, metadata); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMBatchCustomGroupMemberAttribute {\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("username"); + openapiFields.add("metadata"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMBatchCustomGroupMemberAttribute + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMBatchCustomGroupMemberAttribute.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMBatchCustomGroupMemberAttribute is not found in the empty JSON string", EMBatchCustomGroupMemberAttribute.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMBatchCustomGroupMemberAttribute.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMBatchCustomGroupMemberAttribute` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMBatchCustomGroupMemberAttribute.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMBatchCustomGroupMemberAttribute' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMBatchCustomGroupMemberAttribute.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMBatchCustomGroupMemberAttribute value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMBatchCustomGroupMemberAttribute read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMBatchCustomGroupMemberAttribute given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMBatchCustomGroupMemberAttribute + * @throws IOException if the JSON string is invalid with respect to EMBatchCustomGroupMemberAttribute + */ + public static EMBatchCustomGroupMemberAttribute fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMBatchCustomGroupMemberAttribute.class); + } + + /** + * Convert an instance of EMBatchCustomGroupMemberAttribute to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttributeResult.java b/src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttributeResult.java new file mode 100644 index 000000000..ef3aa15b4 --- /dev/null +++ b/src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttributeResult.java @@ -0,0 +1,185 @@ +/* + * EMService + * Easemob Rest API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.easemob.im.api.model; + +import com.easemob.im.JSON; +import com.google.gson.*; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * EMBatchCustomGroupMemberAttributeResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-11-20T13:46:13.002389+08:00[Asia/Shanghai]") +public class EMBatchCustomGroupMemberAttributeResult { + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private Object data; + + public EMBatchCustomGroupMemberAttributeResult() { + } + + public EMBatchCustomGroupMemberAttributeResult data(Object data) { + + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + + public void setData(Object data) { + this.data = data; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EMBatchCustomGroupMemberAttributeResult batchCustomGroupMemberAttributeResult = (EMBatchCustomGroupMemberAttributeResult) o; + return Objects.equals(this.data, batchCustomGroupMemberAttributeResult.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EMBatchCustomGroupMemberAttributeResult {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EMBatchCustomGroupMemberAttributeResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EMBatchCustomGroupMemberAttributeResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EMBatchCustomGroupMemberAttributeResult is not found in the empty JSON string", EMBatchCustomGroupMemberAttributeResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!EMBatchCustomGroupMemberAttributeResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMBatchCustomGroupMemberAttributeResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EMBatchCustomGroupMemberAttributeResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EMBatchCustomGroupMemberAttributeResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EMBatchCustomGroupMemberAttributeResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EMBatchCustomGroupMemberAttributeResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EMBatchCustomGroupMemberAttributeResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EMBatchCustomGroupMemberAttributeResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of EMBatchCustomGroupMemberAttributeResult + * @throws IOException if the JSON string is invalid with respect to EMBatchCustomGroupMemberAttributeResult + */ + public static EMBatchCustomGroupMemberAttributeResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EMBatchCustomGroupMemberAttributeResult.class); + } + + /** + * Convert an instance of EMBatchCustomGroupMemberAttributeResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/test/java/com/easemob/im/api/MetadataApiTest.java b/src/test/java/com/easemob/im/api/MetadataApiTest.java index 9fe82f896..02e7a47ab 100644 --- a/src/test/java/com/easemob/im/api/MetadataApiTest.java +++ b/src/test/java/com/easemob/im/api/MetadataApiTest.java @@ -35,6 +35,86 @@ public class MetadataApiTest extends AbstractTest { public MetadataApiTest() { } + /** + * 批量设置群成员自定义属性 + *

+ * 批量设置群成员的自定义属性(key-value),例如,在群组中的昵称和头像等。每次请求最多可为 20 个群成员设置多个属性,而且可对不同群成员设置不同属性。传入相同用户 ID 时,若其属性名称不同,则添加,相同则更新。文档介绍:https://doc.easemob.com/document/server-side/group_member.html#%E6%89%B9%E9%87%8F%E8%AE%BE%E7%BD%AE%E7%BE%A4%E6%88%90%E5%91%98%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7 + * + * @throws ApiException if the Api call fails + */ + @Test + public void batchCustomGroupMemberAttributeTest() throws ApiException { + String username1 = randomUserName(); + String username2 = randomUserName(); + String username3 = randomUserName(); + String password = "123456"; + + List emCreateUserList = new ArrayList<>(); + EMCreateUser createUser1 = new EMCreateUser(); + createUser1.setUsername(username1); + createUser1.setPassword(password); + + EMCreateUser createUser2 = new EMCreateUser(); + createUser2.setUsername(username2); + createUser2.setPassword(password); + + EMCreateUser createUser3 = new EMCreateUser(); + createUser3.setUsername(username3); + createUser3.setPassword(password); + + emCreateUserList.add(createUser1); + emCreateUserList.add(createUser2); + emCreateUserList.add(createUser3); + + assertDoesNotThrow(() -> userApi.createUsers(emCreateUserList)); + + EMCreateGroup createGroup = new EMCreateGroup(); + createGroup.setOwner(username1); + createGroup.setGroupname("test-group"); + createGroup.setDescription("元梦之星"); + createGroup.setMaxusers(200); + createGroup.setMembers(Arrays.asList(username2, username3)); + createGroup.setPublic(true); + + EMCreateGroupResult createGroupResult = + assertDoesNotThrow(() -> groupApi.createGroup(createGroup)); + assertNotNull(createGroupResult); + assertNotNull(createGroupResult.getData()); + assertNotNull(createGroupResult.getData().getGroupid()); + + String groupId = createGroupResult.getData().getGroupid(); + + Map metadata = new HashMap<>(); + metadata.put("key1", "value1"); + metadata.put("key2", "value2"); + + List batchCustomGroupMemberAttributes = new ArrayList<>(); + + EMBatchCustomGroupMemberAttribute batchCustomGroupMemberAttribute1 = new EMBatchCustomGroupMemberAttribute(); + batchCustomGroupMemberAttribute1.setUsername(username2); + batchCustomGroupMemberAttribute1.setMetadata(metadata); + + EMBatchCustomGroupMemberAttribute batchCustomGroupMemberAttribute2 = new EMBatchCustomGroupMemberAttribute(); + batchCustomGroupMemberAttribute2.setUsername(username3); + batchCustomGroupMemberAttribute2.setMetadata(metadata); + + batchCustomGroupMemberAttributes.add(batchCustomGroupMemberAttribute1); + batchCustomGroupMemberAttributes.add(batchCustomGroupMemberAttribute2); + + EMBatchCustomGroupMemberAttributeResult batchCustomGroupMemberAttributeResult = assertDoesNotThrow( + () -> api.batchCustomGroupMemberAttribute(groupId, batchCustomGroupMemberAttributes)); + assertNotNull(batchCustomGroupMemberAttributeResult); + assertNotNull(batchCustomGroupMemberAttributeResult.getData()); + + assertDoesNotThrow(() -> userApi.deleteUser(username1)); + assertDoesNotThrow(() -> userApi.deleteUser(username2)); + assertDoesNotThrow(() -> userApi.deleteUser(username3)); + try { + groupApi.deleteGroup(groupId); + } catch (ApiException ignored) { + } + } + /** * 设置群成员自定义属性 *