From ce578234f47220b2578ac2cd41ccc46164bd4baf Mon Sep 17 00:00:00 2001 From: imhao183 Date: Thu, 16 Jan 2020 21:16:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=AE=A4=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojos/OutputGetChatroomInfo.java | 11 +++++ .../cn/wildfirechat/sdk/ChatroomAdmin.java | 9 +++- .../main/java/cn/wildfirechat/sdk/Main.java | 49 +++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/cn/wildfirechat/pojos/OutputGetChatroomInfo.java b/common/src/main/java/cn/wildfirechat/pojos/OutputGetChatroomInfo.java index ebd4b284..a458ed45 100755 --- a/common/src/main/java/cn/wildfirechat/pojos/OutputGetChatroomInfo.java +++ b/common/src/main/java/cn/wildfirechat/pojos/OutputGetChatroomInfo.java @@ -18,6 +18,7 @@ public class OutputGetChatroomInfo { private String desc; private String portrait; private String extra; + private int state; private int memberCount; private long createDt; private long updateDt; @@ -28,6 +29,8 @@ public class OutputGetChatroomInfo { this.desc = chatroomInfo.getDesc(); this.portrait = chatroomInfo.getPortrait(); this.memberCount = memberCount; + this.extra = chatroomInfo.getExtra(); + this.state = chatroomInfo.getState(); this.createDt = chatroomInfo.getCreateDt(); this.updateDt = chatroomInfo.getUpdateDt(); } @@ -98,4 +101,12 @@ public class OutputGetChatroomInfo { public void setExtra(String extra) { this.extra = extra; } + + public int getState() { + return state; + } + + public void setState(int state) { + this.state = state; + } } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/ChatroomAdmin.java b/sdk/src/main/java/cn/wildfirechat/sdk/ChatroomAdmin.java index c13d0a63..36f3d26f 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/ChatroomAdmin.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/ChatroomAdmin.java @@ -6,8 +6,15 @@ import cn.wildfirechat.sdk.model.IMResult; import cn.wildfirechat.sdk.utilities.AdminHttpUtils; public class ChatroomAdmin { - public static IMResult createChatroom(InputCreateChatroom input) throws Exception { + public static IMResult createChatroom(String chatroomId, String title, String desc ,String portrait, String extra, Integer state) throws Exception { String path = APIPath.Create_Chatroom; + InputCreateChatroom input = new InputCreateChatroom(); + input.setChatroomId(chatroomId); + input.setTitle(title); + input.setDesc(desc); + input.setPortrait(portrait); + input.setExtra(extra); + input.setState(state); return AdminHttpUtils.httpJsonPost(path, input, OutputCreateChatroom.class); } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index 8d63cf8a..78ba031e 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -469,6 +469,55 @@ public class Main { System.out.println("destroy user failure"); System.exit(-1); } + + String chatroomId = "chatroomId1"; + String chatroomTitle = "TESTCHATROM"; + String chatroomDesc = "this is a test chatroom"; + String chatroomPortrait = "http://pic.com/test123.png"; + String chatroomExtra = "{\'managers:[\"user1\",\"user2\"]}"; + IMResult chatroomIMResult = ChatroomAdmin.createChatroom(chatroomId,chatroomTitle, chatroomDesc, chatroomPortrait,chatroomExtra,ProtoConstants.ChatroomState.Chatroom_State_Normal); + if (chatroomIMResult != null && chatroomIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && chatroomIMResult.getResult().getChatroomId().equals(chatroomId)) { + System.out.println("create chatroom success"); + } else { + System.out.println("create chatroom failure"); + System.exit(-1); + } + + IMResult getChatroomInfoIMResult = ChatroomAdmin.getChatroomInfo(chatroomId); + if (getChatroomInfoIMResult != null && getChatroomInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + if (!getChatroomInfoIMResult.getResult().getChatroomId().equals(chatroomId) + || !getChatroomInfoIMResult.getResult().getTitle().equals(chatroomTitle) + || !getChatroomInfoIMResult.getResult().getDesc().equals(chatroomDesc) + || !getChatroomInfoIMResult.getResult().getPortrait().equals(chatroomPortrait) + || !getChatroomInfoIMResult.getResult().getExtra().equals(chatroomExtra) + || getChatroomInfoIMResult.getResult().getState() != ProtoConstants.ChatroomState.Chatroom_State_Normal) { + System.out.println("chatroom info incorrect"); + System.exit(-1); + } else { + System.out.println("chatroom info incorrect"); + } + } else { + System.out.println("get chatroom info failure"); + System.exit(-1); + } + + voidIMResult = ChatroomAdmin.destroyChatroom(chatroomId); + if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("destroy chatroom done!"); + } else { + System.out.println("destroy chatroom failure"); + System.exit(-1); + } + + getChatroomInfoIMResult = ChatroomAdmin.getChatroomInfo(chatroomId); + if (getChatroomInfoIMResult != null && getChatroomInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && getChatroomInfoIMResult.getResult().getState() == ProtoConstants.ChatroomState.Chatroom_State_End) { + System.out.println("chatroom destroyed!"); + } else { + System.out.println("chatroom not destroyed!"); + System.exit(-1); + } + + System.out.println("Congratulation, all admin test case passed!!!!!!!"); } static void testRobot() throws Exception {