Commit bfa48dad by DuJunLi

优化代码,解决报错问题

parent 276475bb
......@@ -13,13 +13,13 @@ import com.xiaomai.utils.RandomStringUtil;
import com.xiaomai.utils.XMJSONPath;
import org.apache.commons.lang3.StringUtils;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author adu
......@@ -62,7 +62,6 @@ public class TestCreateMemberCluster extends BaseTestImpl {
body.put("description", "自动化测试创建客户分群");
body.put("requireFullHit", "YES");
List<JSONObject> ruleList = new ArrayList<>();
JSONObject ruleTypeTag = new JSONObject();
List<String> tags = new ArrayList<>();
......@@ -92,9 +91,27 @@ public class TestCreateMemberCluster extends BaseTestImpl {
body.put("ruleList", ruleList);
//1.创建人群
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
if ("最多只能新建20个,已达上限".equals(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"))) {
//删除人群(过滤掉存量的2条数据)
memberClusterTools.getMemberClusterList();
XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").toJavaList(JSONObject.class).stream()
.filter(object -> !"满足所有条件便签课程和储值卡(勿动)".equals(object.getString("name")) && !"满足任意一个条件会员分群(勿动)".equals(object.getString("name")))
.map(o -> o.getString("id"))
.collect(Collectors.toList())
.stream()
.forEach(s -> {
memberClusterTools.deleteMemberCluster(s);
});
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
}
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"));
clusterIdNewA = XMJSONPath.readPath(xmAppApi.getApi_response(), "$.result");
//2.查看详情,check人群信息
memberClusterTools.getMemberClusterDetail(clusterIdNewA);
//2.1 check创建的是不是满足所有条件
......@@ -104,9 +121,12 @@ public class TestCreateMemberCluster extends BaseTestImpl {
//3.再创建一个分群,条件是满足以上任意一个,用工具类
String nameB = "满足任意一个条件会员分群" + RandomStringUtil.randomString(3);
memberClusterTools.createMemberCluster(nameB, "", "NO", ruleList);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
clusterIdNewB = XMJSONPath.readPath(dataApi.getApi_response(), "$.result");
//4.查看列表,check是否包含刚创建的人群
memberClusterTools.getMemberClusterList();
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").toJavaList(JSONObject.class).stream().filter(e -> e.getString("id").equals(clusterIdNewA)).count() == 1, "列表中没获取到刚创建的会员分群(满足所有条件)");
......@@ -115,8 +135,8 @@ public class TestCreateMemberCluster extends BaseTestImpl {
memberClusterTools.manuaUpdatelMemberCluster();
if (XMJSONPath.readPath(dataApi.getApi_response(), "$.message").equals("请稍后再试,手动更新需要间隔一小时")) {
//5.1 如果遇到这种场景,那么就启动存量数据了
clusterIdA = "1850830131517263874";
clusterIdB = "1850835279266254850";
clusterIdA = "1867049524725911554";
clusterIdB = "1867049901500239874";
} else {
//5.2 可以操作手动更新时,用新数据
......@@ -259,7 +279,7 @@ public class TestCreateMemberCluster extends BaseTestImpl {
}
@AfterTest(description = "删除此case创建的会员分群")
@Test(description = "删除此case创建的会员分群",priority = 1)
public void delData() {
if (!StringUtils.isEmpty(this.clusterIdNewA)) {
memberClusterTools.deleteMemberCluster(clusterIdNewA);
......
......@@ -10,13 +10,13 @@ import com.xiaomai.utils.RandomStringUtil;
import com.xiaomai.utils.XMJSONPath;
import org.apache.commons.lang3.StringUtils;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 编辑会员分群
......@@ -39,6 +39,18 @@ public class TestEditMemberCluster extends BaseTestImpl {
@Test(description = "测试编辑人群")
public void testEditMemberCluster() {
//先查看人群列表数据,超过20个时,做下删除处理
memberClusterTools.getMemberClusterList();
if("最多只能新建20个,已达上限".equals(XMJSONPath.readPath(dataApi.getApi_response(), "$.message"))){
//删除人群(过滤掉存量的2条数据)
XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").toJavaList(JSONObject.class).stream()
.filter(object ->! "满足所有条件便签课程和储值卡(勿动)".equals(object.getString("name"))&& ! "满足任意一个条件会员分群(勿动)".equals(object.getString("name")))
.map(o->o.getString("id"))
.collect(Collectors.toList())
.stream()
.forEach(s -> {memberClusterTools.deleteMemberCluster(s);} );
}
//1.创建人群
//1.1 人群名称验重
name = "用于自动化测试编辑会员分群动态数据";
......@@ -114,7 +126,7 @@ public class TestEditMemberCluster extends BaseTestImpl {
}
@AfterTest(description = "删除此case创建的会员分群")
@Test(description = "删除此case创建的会员分群",priority = 1)
public void delData() {
if (!StringUtils.isEmpty(this.clusterId)) {
......
......@@ -95,7 +95,7 @@ public class TestDelCurrentAndSubsequentCampSchedule extends SelectTargetTrainin
}
@AfterTest(description = "删除此case创建的训练营排课日程")
@Test(description = "删除此case创建的训练营排课日程",priority = 1)
public void delData() {
//先删除规则,再操作删除对应的训练营活动,此处顺序不能换,如果先删除训练营活动,对应的排课会自动删除,所以就不用删除排课日程了,这个场景其他case中会体现
if (null != ruldId || !ruldId.isEmpty()) {
......
......@@ -90,7 +90,7 @@ public class TestDelCurrentCampScheduleItem extends SelectTargetTrainingCampAndG
}
@AfterTest(description = "删除此case创建的训练营排课日程")
@Test(description = "删除此case创建的训练营排课日程",priority = 1)
public void delData() {
//先删除规则,再操作删除对应的训练营活动,此处顺序不能换,如果先删除训练营活动,对应的排课会自动删除,所以就不用删除排课日程了,这个场景其他case中会体现
if (null != ruldId || !ruldId.isEmpty()) {
......
......@@ -164,7 +164,7 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
}
@AfterTest(description = "删除此case创建的训练营排课日程")
@Test(description = "删除此case创建的训练营排课日程",priority = 1)
public void delData() {
if (null != ruldId || !ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId);
......
......@@ -110,7 +110,7 @@ public class TestEditCurrentCampSchedule extends SelectTargetTrainingCampAndGetI
}
}
@AfterTest(description = "删除此case创建的训练营排课日程")
@Test(description = "删除此case创建的训练营排课日程",priority = 1)
public void delData() {
if (null != campId || !campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
......
......@@ -131,7 +131,7 @@ public class TestGetCampScheduleItemDetail extends SelectTargetTrainingCampAndGe
}
@AfterTest(description = "删除此case创建的训练营排课日程")
@Test(description = "删除此case创建的训练营排课日程",priority = 1)
public void delData() {
if (null != orderId || !orderId.isEmpty()) {
......
......@@ -111,7 +111,7 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo
Assert.assertTrue(resultCount >= total, "查询到的课表数据和预期不一致");
}
@AfterTest(description = "删除此case创建的训练营排课日程,只操作删除对应的训练营活动即可")
@Test(description = "删除此case创建的训练营排课日程,只操作删除对应的训练营活动即可",priority = 1)
public void delData() {
if (null!=campId||!campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
......
......@@ -59,7 +59,7 @@ public class TestDelCurrentAndSubsequentGroupSchedule extends UniversalDataSched
}
}
@AfterTest(description = "删除此case创建的日程")
@Test(description = "删除此case创建的日程",priority = 1)
public void delData() {
if (!StringUtils.isEmpty(groupRuldId)) {//获取到的日程ID不为空时,则逐个删除相关日程
//删除对应日程
......
......@@ -60,7 +60,7 @@ public class TestDelCurrentSingleGroupSchedule extends UniversalDataScheduling{
}
@AfterTest(description = "删除此case创建的日程")
@Test(description = "删除此case创建的日程",priority = 1)
public void delData() {
if (!StringUtils.isEmpty(groupRuldId)) {//获取到的日程ID不为空时,则逐个删除相关日程
......
......@@ -122,7 +122,7 @@ public class TestEditCurrentAndSubsequentGroupSchedule extends UniversalDataSche
}
@AfterTest(description = "删除此case创建的日程")
@Test(description = "删除此case创建的日程",priority = 1)
public void delData () {
if (!StringUtils.isEmpty(groupRuldId)) {//获取到的日程ID不为空时,则逐个删除相关日程
......
......@@ -90,7 +90,7 @@ public class TestEditCurrentGroupSchedule extends UniversalDataScheduling {
@AfterTest(description = "删除此case创建的日程")
@Test(description = "删除此case创建的日程",priority = 1)
public void delData () {
if (!StringUtils.isEmpty(groupRuldId)) {//获取到的日程ID不为空时,则逐个删除相关日程
......
......@@ -37,7 +37,7 @@ public class TestEditGroupRuleSchedule extends BaseTestImpl {
String theDayBeforeYesterdayTimeTamp = CommUtil.oneKeyGetAddDay(-2);
//获取今天+12天后日期的时间戳(结束时间)
String endDateTimeTamp = CommUtil.getNDayEndTimeTamp(12);
String todayEndDateTimeTamp = CommUtil.getNDayEndTimeTamp(0);
String tomEndDateTimeTamp = CommUtil.getNDayEndTimeTamp(1);
String courseName = "阿杜自动化团课课程";
......@@ -83,7 +83,7 @@ public class TestEditGroupRuleSchedule extends BaseTestImpl {
body.put("assistCoachIds", new ArrayList<>()); //有数据AB改成空
body.put("ruleId", ruldId);
body.put("spanMinutes", 50);
body.put("endDate", todayEndDateTimeTamp); //结束日期缩短了,改成当天结束
body.put("endDate", tomEndDateTimeTamp); //结束日期缩短了,改成明天结束
body.put("force", false);
body.put("retainBooking", true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
......
......@@ -134,7 +134,7 @@ public class TestGetGroupScheduleTable extends BaseTestImpl {
}
@AfterTest(description = "删除此case创建的日程")
@Test(description = "删除此case创建的日程",priority = 1)
public void delData(){
List<String> ruleIdIds = new ArrayList<>();
//查询这个case创建的相关日程
......
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