import com.huahua.esys.control.ActivityAction;
import com.huahua.esys.control.Jhl1484Action;
import com.huahua.esys.control.LiveUtils;
import com.huahua.esys.control.virtualImage.CommonUtil;
import com.huahua.network.common.Environment;
import com.huahua.network.common.LogUtils;
import com.huahua.network.net.BvtHelper;
import com.huahua.network.utility.Utilly;
import net.sf.json.JSONObject;
import org.apache.commons.lang.ObjectUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class PopWindow1617Test {
Environment env = Environment.TEST_PEPPER_ACTIVITY;
BvtHelper bvthelper = new BvtHelper();
Utilly utils = new Utilly();
Jhl1484Action jhl1484Action = new Jhl1484Action();
ActivityAction activityAction = new ActivityAction();
LiveUtils liveUtils = new LiveUtils();
PopWindow1617Action popWindow1617Action = new PopWindow1617Action();
String testIp = "popwindow1617.activity.test.huahua.com";
Object uid = 43008476;
Object author = 45755591;
Object uidToken = "";
Object liveid = liveUtils.getCurrentLiveid(author);
@BeforeClass
public void beforeClass() {
if (env == Environment.PEPPER_ACTIVITY) {
testIp = "popwindow1617.activity.huahua.com";
uid = 252860815;
author = 220652118;
}
uidToken = utils.getTokenV2(uid);
}
@DataProvider
public Object[][] data_resetPop() {
int scene = 1;
String appName = "huahua";
return new Object[][]{
};
}
@Test(dataProvider = "data_resetPop")
public void resetPop(int id, String casename, String token, Object uid, Object scene, String appName, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.resetPop(testIp, token, uid, scene, appName));
Assert.assertEquals(result.getInt("errno"), exp);
}
@DataProvider
public Object[][] data_resetUnique() {
int uniqueId = 1520;
String appName = "huahua";
return new Object[][]{
};
}
@Test(dataProvider = "data_resetUnique")
public void resetUnique(int id, String casename, String token, Object uid, Object uniqueId, String appName, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.resetUnique(testIp, token, uid, uniqueId, appName));
Assert.assertEquals(result.getInt("errno"), exp);
}
@DataProvider
public Object[][] data_loginPop() {
String appName = "huahua";
return new Object[][]{
new Object[]{0, "启动-252860815", utils.getTokenV2(45864027), appName, 0},
};
}
@DataProvider
public Object[][] data_joinRoomPop() {
String appName = "huahua";
return new Object[][]{
};
}
@DataProvider
public Object[][] data_pushPopMessage() {
String appName = "huahua";
String uniqueId = "1200";
int scene = 1;
int sequence = 1;
int priority = 12;
String slot = "1";
String url1 = "https://web.test.huahua.com/jimu/222/index.html";
String url2 = "https://activity.test.huahua.com/web/share/banner/2022/luckyBag/popup.html";
return new Object[][]{
};
}
@DataProvider
public Object[][] data_getRedisKey() {
String key0 = "buildKey:value:PopWindow:1617:0:uid:login:count:252105928:20220713:huahua";
return new Object[][]{
};
}
@Test(dataProvider = "data_getRedisKey")
public void getRedisKey(int id, String casename, String token, String key, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.getRedisKey(testIp, token, key));
Assert.assertEquals(result.getInt("errno"), exp);
}
@DataProvider
public Object[][] data_setRedisKey() {
String key3 = "buildKey:value:PopWindow:1617:0:uid:pop:window:close:day:1319:252608592:huahua";
String key_3 = "buildKey:value:PopWindow:1617:0:uid:close:pop:window:count:1319:252608592:huahua";
String value1 = "20220510";
String value_1 = "0";
return new Object[][]{
};
}
@Test(dataProvider = "data_setRedisKey")
public void setRedisKey(int id, String casename, String token, String key, String value, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.setRedisKey(testIp, token, key, value));
Assert.assertEquals(result.getInt("errno"), exp);
}
@DataProvider
public Object[][] data_isClose() {
String appName = "huahua";
String uniqueId = "1520";
String slotId = "20220628_2_1_1";
int close = 1;
return new Object[][]{
};
}
@DataProvider
public Object[][] data_rescueMessage() {
int scene = 2;
int sequence = 1;
String uniqueId = "1520";
String action = "update";
String appName = "huahua";
String slot = "1";
return new Object[][]{
};
}
@DataProvider
public Object[][] data_pop() {
String appName = "huahua";
String uniqueId = "1600";
String slotId = "20220517_1_1_2";
return new Object[][]{
};
}
@Test(dataProvider = "data_loginPop")
public void loginPop(int id, String casename, String token, String appName, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.loginPop(testIp, token, appName));
Assert.assertEquals(result.getInt("errno"), exp);
}
@Test(dataProvider = "data_isClose")
public void isClose(int id, String casename, String token, String appName, String uniqueId, String slotId, Object close, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.isClose(testIp, token, appName, uniqueId, slotId, close));
Assert.assertEquals(result.getInt("errno"), exp);
}
@Test(dataProvider = "data_pushPopMessage")
public void pushPopMessage(int id, String casename, String token, Object uid, Object scene, Object sequence, Object priority, String slot, String uniqueId, String appName, Object url1, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.pushPopMessage(testIp, token, uid, scene, sequence, priority, slot, uniqueId, appName, url1));
Assert.assertEquals(result.getInt("errno"), exp);
}
@Test(dataProvider = "data_rescueMessage")
public void rescueMessage(int id, String casename, String token, Object scene, Object sequence, String uniqueId, String action, String appName, String slot, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.rescueMessage(testIp, token, scene, sequence, uniqueId, action, appName, slot));
Assert.assertEquals(result.getInt("errno"), exp);
}
@Test(dataProvider = "data_pop")
public void pop(int id, String casename, String token, String appName, String uniqueId, String slotId, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.pop(testIp, token, appName, uniqueId, slotId));
Assert.assertEquals(result.getInt("errno"), exp);
}
@Test(dataProvider = "data_joinRoomPop")
public void joinRoomPop(int id, String casename, String token, String appName, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.joinRoomPop(testIp, token, appName));
Assert.assertEquals(result.getInt("errno"), exp);
}
@DataProvider
public Object[][] data_isPermitPop() {
String versionId = "8.3.8";
return new Object[][]{
};
}
@Test(dataProvider = "data_isPermitPop")
public void isPermitPop(int id, String casename, String token, Object uid, String version, int exp) {
LogUtils.printTitle(id, casename);
JSONObject result = JSONObject.fromObject(popWindow1617Action.isPermitPop(testIp, token, uid, version));
Assert.assertEquals(result.getInt("errno"), exp);
}
class PopWindow1617Action {
public Object loginPop(String ip, String token, String appName) {
String uri = "PopWindow/loginPop";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (appName != null) {
params.put("appName", appName);
}
if (token != null) {
params.put("token", token);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object joinRoomPop(String ip, String token, String appName) {
String uri = "PopWindow/joinRoomPop";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (appName != null) {
params.put("appName", appName);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object isClose(String ip, String token, String appName, String uniqueId, String slotId, Object close) {
String uri = "PopWindow/isClose";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (appName != null) {
params.put("appName", appName);
}
if (uniqueId != null) {
params.put("uniqueId", uniqueId);
}
if (slotId != null) {
params.put("slotId", slotId);
}
if (close != null) {
params.put("close", close);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object pop(String ip, String token, String appName, String uniqueId, String slotId) {
String uri = "PopWindow/pop";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (appName != null) {
params.put("appName", appName);
}
if (uniqueId != null) {
params.put("uniqueId", uniqueId);
}
if (slotId != null) {
params.put("slotId", slotId);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object pushPopMessage(String ip, String token, Object uid, Object scene, Object sequence, Object priority, String slot, String uniqueId, String appName, Object url1) {
String uri = "PopWindow/pushPopMessage";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (appName != null) {
params.put("appName", appName);
}
if (uniqueId != null) {
params.put("uniqueId", uniqueId);
}
if (uid != null) {
params.put("uid", uid);
}
if (scene != null) {
params.put("scene", scene);
}
if (sequence != null) {
params.put("sequence", sequence);
}
if (priority != null) {
params.put("priority", priority);
}
if (slot != null) {
params.put("slot", slot);
}
if (url1 != null) {
params.put("url", url1);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object isPermitPop(String ip, String token, Object uid, String versionId) {
String uri = "PopWindow/isPermitPop";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (uid != null) {
params.put("uid", uid);
}
if (versionId != null) {
params.put("versionId", versionId);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object rescueMessage(String ip, String token, Object scene, Object sequence, String uniqueId, String action, String appName, String slot) {
String uri = "PopWindow/rescueMessage";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (scene != null) {
params.put("scene", scene);
}
if (sequence != null) {
params.put("sequence", sequence);
}
if (uniqueId != null) {
params.put("uniqueId", uniqueId);
}
if (action != null) {
params.put("action", action);
}
if (appName != null) {
params.put("appName", appName);
}
if (slot != null) {
params.put("slot", slot);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object resetPop(String ip, String token, Object uid, Object scene, String appName) {
String uri = "PopWindow/resetPop";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (uid != null) {
params.put("uid", uid);
}
if (scene != null) {
params.put("scene", scene);
}
if (appName != null) {
params.put("appName", appName);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object resetUnique(String ip, String token, Object uid, Object uniqueId, String appName) {
String uri = "PopWindow/resetUnique";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (uid != null) {
params.put("uid", uid);
}
if (uniqueId != null) {
params.put("uniqueId", uniqueId);
}
if (appName != null) {
params.put("appName", appName);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object getRedisKey(String ip, String token, String key) {
String uri = "PopWindow/getRedisKey";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (key != null) {
params.put("key", key);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
public Object setRedisKey(String ip, String token, String key, String value) {
String uri = "PopWindow/setRedisKey";
String url = String.format("%s://%s/%s%s", CommonUtil.replaceHost(ip), ip, uri, utils.buildClientGUID("ios","8.4.1"));
Map<String, String> headers = new HashMap<>();
headers.put("Host", ip.contains("test") ? "popwindow1617.activity.test.huahua.com" : "popwindow1617.activity.huahua.com");
headers.put("Cookie", "token=" + token);
Map<String, Object> params = new HashMap<String, Object>();
if (key != null) {
params.put("key", key);
}
if (value != null) {
params.put("value", value);
}
StringBuilder paramsa = bvthelper.builder(params);
return bvthelper.sendandget(url, paramsa, headers, true, "form");
}
}
}