聊天室相关测试代码
This commit is contained in:
@@ -18,6 +18,7 @@ public class OutputGetChatroomInfo {
|
|||||||
private String desc;
|
private String desc;
|
||||||
private String portrait;
|
private String portrait;
|
||||||
private String extra;
|
private String extra;
|
||||||
|
private int state;
|
||||||
private int memberCount;
|
private int memberCount;
|
||||||
private long createDt;
|
private long createDt;
|
||||||
private long updateDt;
|
private long updateDt;
|
||||||
@@ -28,6 +29,8 @@ public class OutputGetChatroomInfo {
|
|||||||
this.desc = chatroomInfo.getDesc();
|
this.desc = chatroomInfo.getDesc();
|
||||||
this.portrait = chatroomInfo.getPortrait();
|
this.portrait = chatroomInfo.getPortrait();
|
||||||
this.memberCount = memberCount;
|
this.memberCount = memberCount;
|
||||||
|
this.extra = chatroomInfo.getExtra();
|
||||||
|
this.state = chatroomInfo.getState();
|
||||||
this.createDt = chatroomInfo.getCreateDt();
|
this.createDt = chatroomInfo.getCreateDt();
|
||||||
this.updateDt = chatroomInfo.getUpdateDt();
|
this.updateDt = chatroomInfo.getUpdateDt();
|
||||||
}
|
}
|
||||||
@@ -98,4 +101,12 @@ public class OutputGetChatroomInfo {
|
|||||||
public void setExtra(String extra) {
|
public void setExtra(String extra) {
|
||||||
this.extra = extra;
|
this.extra = extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(int state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,15 @@ import cn.wildfirechat.sdk.model.IMResult;
|
|||||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||||
|
|
||||||
public class ChatroomAdmin {
|
public class ChatroomAdmin {
|
||||||
public static IMResult<OutputCreateChatroom> createChatroom(InputCreateChatroom input) throws Exception {
|
public static IMResult<OutputCreateChatroom> createChatroom(String chatroomId, String title, String desc ,String portrait, String extra, Integer state) throws Exception {
|
||||||
String path = APIPath.Create_Chatroom;
|
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);
|
return AdminHttpUtils.httpJsonPost(path, input, OutputCreateChatroom.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -469,6 +469,55 @@ public class Main {
|
|||||||
System.out.println("destroy user failure");
|
System.out.println("destroy user failure");
|
||||||
System.exit(-1);
|
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<OutputCreateChatroom> 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<OutputGetChatroomInfo> 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 {
|
static void testRobot() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user