Commit 9f4f8dde by yangfangfang

新增通用设置-标签管理相关case

parent 055011f2
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="通用设置场景case"> <!-- 起一个好听且唯一的名字-->
<test name="通用设置模块测试" preserve-order="true" verbose="3"> <!-- 再起一个听且唯一的名字 -->
<packages>
<package name="com.xiaomai.cases.polar.setting.*"></package> <!-- 添加自己想要集成测试的case 范围自己定 -->
</packages>
</test>
<listeners>
<listener class-name="com.xiaomai.client.RetryListener" />
<listener class-name="com.xiaomai.client.TestListener" />
<listener class-name="com.xiaomai.client.ExtentTestNGIReporterListener"/>
</listeners>
</suite>
\ No newline at end of file
package com.xiaomai.cases.polar.setting;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.client.DataUserInfo;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
public class TagTools extends XMBaseTest {
/**
* @param
* @description:添加标签
* @author: yangfangfang
* @date: 2024/3/5 11:28
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject tagCreate(String label, DataUserInfo...dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Setting)
.setApiName("API_tag_create")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("bizAccountId",xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("label", label);
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response=dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:删除标签
* @author: yangfangfang
* @date: 2024/3/5 14:28
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject tagDelete(String id,DataUserInfo...dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Setting)
.setApiName("API_tag_deleteById")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
JSONObject deleteTag=new JSONObject();
deleteTag.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
deleteTag.put("brandId",xmAppApi.getLoginInfo().getBrandId());
deleteTag.put("studioId",xmAppApi.getLoginInfo().getStudioId());
deleteTag.put("id",id);
deleteTag.put("confirm","");
dataApi.doRequest(RequestType.JSON, dataparams, deleteTag.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response=dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:删除标签
* @author: yangfangfang
* @date: 2024/3/5 16:28
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject tagFetchPage(String content,DataUserInfo...dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Setting)
.setApiName("API_tag_fetchPage")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject=new JSONObject();
jsonObject.put("size",20);
jsonObject.put("current",0);
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("needUsageInfo","true");
jsonObject.put("content",content);
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response=dataApi.getBodyInJSON();
return response;
}
}
\ No newline at end of file
package com.xiaomai.cases.polar.setting.tag;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.setting.TagTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.RandomStringUtil;
import com.xiaomai.utils.XMBaseTest;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestCreate extends XMBaseTest {
String tagId1;
String tagId2;
TagTools tagTools=new TagTools();
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Setting)
.setApiName("API_tag_create")
.setLoginUser(LoginAccount.YFF_DEV)
.setTerminal(Terminal.B);
dal.setCase_owner("yff")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "添加标签-成功")
public void testCreate(){
//获取当前标签列表
JSONObject fetchPage=tagTools.tagFetchPage("");
int total= Integer.parseInt(fetchPage.getJSONObject("result").getString("total"));
//添加标签
JSONObject jsonObject=new JSONObject();
jsonObject.put("bizAccountId",xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("label","自动化"+ RandomStringUtil.randomString(3));
xmAppApi.doRequest(RequestType.JSON,params,jsonObject.toJSONString(),headers).assetsSuccess(true);
JSONObject response=xmAppApi.getBodyInJSON();
tagId1=response.getString("result");
String success=response.getString("success");
Assert.assertEquals(success,"true","添加标签失败");
JSONObject fetchPage2=tagTools.tagFetchPage("");
int total2= Integer.parseInt(fetchPage2.getJSONObject("result").getString("total"));
boolean flag=false;
if(total2==(total+1)){
flag=true;
}
Assert.assertEquals(flag,true,"添加标签失败");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Test(description = "添加相同名称标签-失败")
public void testCreateSameName(){
//添加第一个标签
JSONObject createTag=tagTools.tagCreate("自动化-禁止使用");
tagId2=createTag.getString("result");
//添加第二个标签名称与第一个相同
JSONObject jsonObject=new JSONObject();
jsonObject.put("bizAccountId",xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("label","自动化-禁止使用");
xmAppApi.doRequest(RequestType.JSON,params,jsonObject.toJSONString(),headers).assetsSuccess(false);
JSONObject response=xmAppApi.getBodyInJSON();
String code=response.getString("code");
String success=response.getString("success");
Assert.assertEquals(success,"false","相同标签不能添加,但可添加");
Assert.assertEquals(code,"error/.TAG_NAME_DUPLICATE","同标签名已存在,不可重复");
}
@Test(description = "删除标签",priority = 1)
public void deleteTag(){
tagTools.tagDelete(tagId1);
tagTools.tagDelete(tagId2);
}
}
package com.xiaomai.cases.polar.setting.tag;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.setting.TagTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.RandomStringUtil;
import com.xiaomai.utils.XMBaseTest;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestDeleteById extends XMBaseTest {
TagTools tagTools=new TagTools();
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Setting)
.setApiName("API_tag_deleteById")
.setLoginUser(LoginAccount.YFF_DEV)
.setTerminal(Terminal.B);
dal.setCase_owner("yff")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "删除标签--未被会员使用")
public void testDeleteById(){
//获取当前标签列表
JSONObject fetchPage=tagTools.tagFetchPage("");
int total= Integer.parseInt(fetchPage.getJSONObject("result").getString("total"));
//添加标签
JSONObject createTag=tagTools.tagCreate("自动化"+ RandomStringUtil.randomString(3));
String tagId=createTag.getString("result");
//删除标签
JSONObject deleteTag=new JSONObject();
deleteTag.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
deleteTag.put("brandId",xmAppApi.getLoginInfo().getBrandId());
deleteTag.put("studioId",xmAppApi.getLoginInfo().getStudioId());
deleteTag.put("id",tagId);
deleteTag.put("confirm","");
xmAppApi.doRequest(RequestType.JSON,params,deleteTag.toJSONString(),headers).assetsSuccess(true);
JSONObject response=xmAppApi.getBodyInJSON();
String result=response.getJSONObject("result").getString("success");
Assert.assertEquals(result,"true","删除标签失败");
//获取当前标签列表
JSONObject fetchPage2=tagTools.tagFetchPage("");
int total2= Integer.parseInt(fetchPage2.getJSONObject("result").getString("total"));
Assert.assertEquals(total2,total,"删除标签失败");
}
// @Test(description = "删除标签--已被会员使用")//待添加线索之后再补充
}
package com.xiaomai.cases.polar.setting.tag;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.setting.TagTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.RandomStringUtil;
import com.xiaomai.utils.XMBaseTest;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestEdit extends XMBaseTest {
TagTools tagTools=new TagTools();
String tagId;
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Setting)
.setApiName("API_tag_edit")
.setLoginUser(LoginAccount.YFF_DEV)
.setTerminal(Terminal.B);
dal.setCase_owner("yff")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "编辑标签--未被会员使用")
public void testEdit(){
//添加标签
JSONObject createTag=tagTools.tagCreate("自动化专用"+RandomStringUtil.randomString(2));
tagId=createTag.getString("result");
//编辑标签
JSONObject jsonObject=new JSONObject();
jsonObject.put("bizAccountId",xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("label","自动化编辑"+RandomStringUtil.randomString(2));
jsonObject.put("id",tagId);
xmAppApi.doRequest(RequestType.JSON,params,jsonObject.toJSONString(),headers).assetsSuccess(true);
JSONObject response=xmAppApi.getBodyInJSON();
String success=response.getJSONObject("result").getString("success");
Assert.assertEquals(success,"true","编辑标签失败");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// @Test(description = "编辑标签--已被会员使用")//待添加线索之后再补充
//删除标签
@Test(description = "删除标签",priority = 1)
public void deleteTag(){
tagTools.tagDelete(tagId);
}
}
package com.xiaomai.cases.polar.setting.tag;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestFetchPage extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Setting)
.setApiName("API_tag_fetchPage")
.setLoginUser(LoginAccount.YFF_DEV)
.setTerminal(Terminal.B);
dal.setCase_owner("yff")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "获取标签列表")
public void testFetchPage(){
JSONObject jsonObject=new JSONObject();
jsonObject.put("size",20);
jsonObject.put("current",0);
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("needUsageInfo","true");
xmAppApi.doRequest(RequestType.JSON,params,jsonObject.toJSONString(),headers).assetsSuccess(true);
JSONObject response=xmAppApi.getBodyInJSON();
String success=response.getString("success");
Assert.assertEquals(success,"true","获取标签列表失败");
}
}
......@@ -7,5 +7,6 @@ package com.xiaomai.enums;
public class ApiModule {
public static String Polar_Admin ="polar_admin";
public static String Polar_Config ="polar_config";
public static String Polar_Setting ="polar_setting";//通用设置
}
\ No newline at end of file
......@@ -7,4 +7,6 @@ package com.xiaomai.enums;
*/
public class LoginAccount {
public static String XYM_DEV = "xym_dev";
public static String YFF_DEV = "yff_dev";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment