Commit 276475bb by DuJunLi
parents 47d17e78 e974aa63
......@@ -6,7 +6,6 @@ import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
......@@ -58,7 +57,7 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
ruldId=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").getJSONObject(0).getString("ruleId");
}
@AfterTest(description = "删除此case创建的训练营排课日程和训练营活动")
@Test(description = "删除此case创建的训练营排课日程和训练营活动",priority = 1)
public void delData() {
//直接删除训练营会的,对应的排课日程会被自动删除,校验其他case中已有
if (null!=this.campId||!this.campId.isEmpty()) {
......
......@@ -871,7 +871,7 @@ public class VenueAreaTools extends XMBaseTest {
dataApi.doRequest(RequestType.JSON, dataparams, object.toString(), dataheadrs).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.result"),"SUCCESS");
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.identifier"),venueBookingRecordId);
// Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.identifier"),venueBookingRecordId);
}
/**
* 小程序取消场地预约
......
package com.xiaomai.cases.polar.training;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
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.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.annotation.Resource;
public class TestTrainingExerciseEdit extends BaseTestImpl {
@Resource(name="trainingTools")
TrainingTools trainingTools;
String exerciseName = "其他部位";
@BeforeMethod
@Override
public void beforeTest(){
setTestInfo(ApiModule.Polar_Training,"API_trainingExerciseEdit", LoginAccount.GYM_PROD, Terminal.B,"xyy");
super.beforeTest();
}
@Test(description = "创建动作>查看详情>编辑动作>删除动作")
public void testTrainingExerciseEdit(){
//1.获取动作库-其他部位的数据
String bodyPartId = XMJSONPath.readPath(trainingTools.getBodyPartList(),"$.result[-1].id");//其他部位id
int num = XMJSONPath.getJSONArrayByReadPath(trainingTools.trainingExerciseList(bodyPartId),"$.result").size();
//2.创建动作
//若重名,则换一个名称
boolean flag = trainingTools.trainingExerciseCheckName("",exerciseName);
if(flag==false){
exerciseName = "其他部位"+ RandomStringUtil.randomString(5);
}
String exerciseId = trainingTools.trainingExerciseCreate(exerciseName,bodyPartId);
//检验其他部位的数据+1
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(trainingTools.trainingExerciseList(bodyPartId),"$.result").size()==num+1);
//检验动作详情,动作名称正确、部位有值;
Assert.assertEquals(XMJSONPath.readPath(trainingTools.trainingExerciseGetDetail(exerciseId),"$.result.name"),exerciseName);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(trainingTools.trainingExerciseGetDetail(exerciseId),"$.result.trainingBodyPartList").size()==1);
//编辑动作的新名称
String editName = "编辑其他部位"+ RandomStringUtil.randomString(5);
//3.编辑动作
JSONArray bodyPartIds = new JSONArray();
bodyPartIds.add(bodyPartId);
JSONObject body = new JSONObject();
body.put("name", editName);
body.put("bodyPartIds",bodyPartIds);
body.put("muscle","自动化脚本编辑训练肌肉");
body.put("actionStandards","自动化脚本编辑动作标准");
body.put("notes","自动化脚本编辑注意事项");
body.put("id",exerciseId);
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
//检验动作详情,编辑的新动作名称正确;
Assert.assertEquals(XMJSONPath.readPath(trainingTools.trainingExerciseGetDetail(exerciseId),"$.result.name"),editName);
//4.删除动作
trainingTools.trainingExerciseDelete(exerciseId);
//检验其他部位的数据-1
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(trainingTools.trainingExerciseList(bodyPartId),"$.result").size()==num);
}
}
package com.xiaomai.cases.polar.training;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
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.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.UUID;
public class TestTrainingTemplateEdit extends BaseTestImpl {
@Resource(name="trainingTools")
TrainingTools trainingTools;
String templateName = "训练模板";
String itemName = "饮食搭配";//模板内容标题
String itemType = "GRAPHIC";//模板内容类型
@BeforeMethod
@Override
public void beforeTest(){
setTestInfo(ApiModule.Polar_Training,"API_trainingTemplateEdit", LoginAccount.GYM_PROD, Terminal.B,"xyy");
super.beforeTest();
}
@Test(description = "创建模板>查看模板详情>编辑模板>删除模板")
public void testTrainingExerciseEdit()throws InterruptedException{
//1.检验名称是否重名,若重名则换一个名称
boolean flag = trainingTools.trainingTemplateCheckName("",templateName);
if(flag==false){
templateName = "训练模板"+ RandomStringUtil.randomString(5);
}
//获取模板数据
int num = Integer.parseInt(XMJSONPath.readPath(trainingTools.trainingTemplateListPage(templateName),"$.result.total"));
//2.创建训练模板
String templateId = trainingTools.trainingTemplateCreate(itemType,itemName,templateName);
Thread.sleep(3000);
//检验模板数据+1
Assert.assertTrue(Integer.parseInt(XMJSONPath.readPath(trainingTools.trainingTemplateListPage(templateName),"$.result.total"))==num+1);
//检验模板详情,模板名称正确、训练内容有值;
Assert.assertEquals(XMJSONPath.readPath(trainingTools.trainingTemplateDetail(templateId),"$.result.templateName"),templateName);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(trainingTools.trainingTemplateDetail(templateId),"$.result.templateItemList").size()>0);
//3.编辑模板
JSONObject exercise = new JSONObject();
exercise.put("objectId", UUID.randomUUID().toString());
exercise.put("itemName","编辑热身运动");
exercise.put("itemType","EXERCISE");//动作EXERCISE
JSONArray itemList = new JSONArray();
itemList.add(exercise);
JSONObject body = new JSONObject();
body.put("trainingTemplateName",templateName);
body.put("trainingTemplateItemList",itemList);
body.put("templateId",templateId);
body.put("studioId",xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("creator",xmAppApi.getLoginInfo().getAdminId());
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
//检验动作详情,训练内容有值;
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(trainingTools.trainingTemplateDetail(templateId),"$.result.templateItemList").size()>0);
//4.删除模板
trainingTools.trainingTemplateDelete(templateId);
//检验模板数据保持跟原来一致
Assert.assertTrue(Integer.parseInt(XMJSONPath.readPath(trainingTools.trainingTemplateListPage(templateName),"$.result.total"))==num);
}
}
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