Commit 2ac981cd by xuyamei

增加操作时间查询

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