Commit 2ac981cd by xuyamei

增加操作时间查询

parent 491b370a
......@@ -12,6 +12,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.Random;
/**
* @BelongsProject: xm-sportstest
......@@ -31,20 +32,29 @@ public class TestDepartStudioAdmin extends BaseTestImpl {
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Admin,"API_departStudioAdmin", LoginAccount.GYM_PROD, Terminal.B,"xym");
setTestInfo(ApiModule.Polar_Admin,"API_departStudioAdmin", LoginAccount.GYM_PROD2, Terminal.B,"xym");
super.beforeTest();
}
@Test
public void testDepartStudioAdmin() {
// 获取在职员工
String body = "{\"size\":10,\"current\":0,\"state\":\"DUTY\"}";
String body = "{\"size\":20,\"current\":0,\"state\":\"DUTY\"}";
JSONObject adminPage = adminTools.pageStudioAdmin(body);
int total = Integer.parseInt(adminPage.getJSONObject("result").getString("total"));
if (total>1){
String adminId = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("id");
String phone = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("phone");
String name = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("name");
int pages = Integer.parseInt(adminPage.getJSONObject("result").getString("pages"));
// 随机获取一页
Random rand = new Random();
int pageIndex = rand.nextInt(pages);
// 随机获取一页的随机员工
Random random = new Random();
int index = pageIndex == pages ? random.nextInt(total%20-1)+1 : random.nextInt(19)+1;
body = "{\"size\":20,\"current\":"+pageIndex+",\"state\":\"DUTY\"}";
adminPage = adminTools.pageStudioAdmin(body);
String adminId = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(index).getString("id");
String phone = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(index).getString("phone");
String name = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(index).getString("name");
body = "{\"id\":\""+adminId+"\"}";
xmAppApi.doRequest(RequestType.JSON,params,body,headers).assetsSuccess(true);
try {
......@@ -58,7 +68,7 @@ public class TestDepartStudioAdmin extends BaseTestImpl {
total = Integer.parseInt(adminPage.getJSONObject("result").getString("total"));
Assert.assertEquals(total,1,"员工离职失败,用手机号查询离职员工未返回数据");
try {
Thread.sleep(1000);
Thread.sleep(12000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
......
......@@ -8,12 +8,14 @@ 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.TimeUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.Random;
/**
* @BelongsProject: xm-sportstest
......@@ -41,9 +43,18 @@ public class TestEditStudioAdmin extends BaseTestImpl {
JSONObject adminPage = adminTools.pageStudioAdmin(body);
int total = Integer.parseInt(adminPage.getJSONObject("result").getString("total"));
if (total>1){
String adminId = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("id");
String name = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("name");
String phone = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("phone");
int pages = Integer.parseInt(adminPage.getJSONObject("result").getString("pages"));
// 随机获取一页
Random rand = new Random();
int pageIndex = rand.nextInt(pages);
// 随机获取一页的随机员工
Random random = new Random();
int index = pageIndex == pages ? random.nextInt(total%20-1)+1 : random.nextInt(19)+1;
body = "{\"size\":20,\"current\":"+pageIndex+",\"state\":\"DUTY\"}";
adminPage = adminTools.pageStudioAdmin(body);
String adminId = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(index).getString("id");
String phone = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(index).getString("phone");
// 修改的请求参数
JSONObject requestBody = new JSONObject();
......@@ -64,10 +75,11 @@ public class TestEditStudioAdmin extends BaseTestImpl {
String memo = "修改员工备注信息"; // 备注
requestBody.put("memo",memo);
String editName = name + "修改";
String name = RandomStringUtil.random_name();
String editName = name + TimeUtils.getCurrentTime();
requestBody.put("name",editName);
String editNickName = name + "修改";
String editNickName = name + TimeUtils.getCurrentTime();
requestBody.put("nickName",editNickName); // 昵称
JSONObject avatar = new JSONObject(); // 头像
......@@ -111,7 +123,7 @@ public class TestEditStudioAdmin extends BaseTestImpl {
System.out.println(adminInfo.getJSONObject("result").getString(resultString[i]));
}
try {
Thread.sleep(1000);
Thread.sleep(15000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
......
......@@ -12,6 +12,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.Random;
/**
* @BelongsProject: xm-sportstest
......@@ -29,7 +30,7 @@ public class TestReinStateStudioAdmin extends BaseTestImpl {
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Admin,"API_reinStateStudioAdmin", LoginAccount.GYM_PROD, Terminal.B,"xym");
setTestInfo(ApiModule.Polar_Admin,"API_reinStateStudioAdmin", LoginAccount.GYM_PROD2, Terminal.B,"xym");
super.beforeTest();
}
......@@ -40,9 +41,19 @@ public class TestReinStateStudioAdmin extends BaseTestImpl {
JSONObject adminPage = adminTools.pageStudioAdmin(body);
int total = Integer.parseInt(adminPage.getJSONObject("result").getString("total"));
if (total>1){
String adminId = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("id");
String phone = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("phone");
String name = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(1).getString("name");
int pages = Integer.parseInt(adminPage.getJSONObject("result").getString("pages"));
// 随机获取一页
Random rand = new Random();
int pageIndex = rand.nextInt(pages);
// 随机获取一页的随机员工
Random random = new Random();
int index = pageIndex == pages ? random.nextInt(total%20-1)+1 : random.nextInt(19)+1;
body = "{\"size\":20,\"current\":"+pageIndex+",\"state\":\"LEFT\"}";
adminPage = adminTools.pageStudioAdmin(body);
String adminId = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(index).getString("id");
String phone = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(index).getString("phone");
String name = adminPage.getJSONObject("result").getJSONArray("records").getJSONObject(index).getString("name");
body = "{\"id\":\""+adminId+"\"}";
xmAppApi.doRequest(RequestType.JSON,params,body,headers).assetsSuccess(true);
try {
......@@ -57,7 +68,7 @@ public class TestReinStateStudioAdmin extends BaseTestImpl {
Assert.assertEquals(total,1,"员工离职失败,用手机号查询离职员工未返回数据");
try {
Thread.sleep(1000);
Thread.sleep(12000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
......
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