|
|
@@ -4,6 +4,8 @@ import com.google.gson.Gson;
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
import com.moka.gdtauto.GdtAutoApplication;
|
|
|
import com.tencent.ads.model.v3.*;
|
|
|
+
|
|
|
+import org.apache.tomcat.util.http.parser.TE;
|
|
|
import org.junit.jupiter.api.DisplayName;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -20,13 +22,18 @@ import java.util.List;
|
|
|
* @since 2026-02-04
|
|
|
*/
|
|
|
@SpringBootTest(classes = GdtAutoApplication.class)
|
|
|
-@ActiveProfiles("local")
|
|
|
+@ActiveProfiles("test")
|
|
|
class TencentAdsAdgroupCreateTest {
|
|
|
|
|
|
@Autowired
|
|
|
private TencentAdsAdgroupService adgroupService;
|
|
|
|
|
|
- private static final Long TEST_ACCOUNT_ID = 66612379L;
|
|
|
+ private static final Long ORG_ACCOUNT_ID = 33453856L;
|
|
|
+ private static final Long TEST_ACCOUNT_ID = 69781948L;
|
|
|
+ private static final String TEST_PHONE = "13057411858";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Test
|
|
|
@DisplayName("测试创建广告-使用提供的测试数据")
|
|
|
@@ -38,7 +45,7 @@ class TencentAdsAdgroupCreateTest {
|
|
|
|
|
|
try {
|
|
|
// 构建测试数据(您提供的JSON数据)
|
|
|
- AdgroupsAddRequest request = buildTestRequest();
|
|
|
+ AdgroupsAddRequest request = buildTestRequest(TEST_ACCOUNT_ID);
|
|
|
|
|
|
// 输出请求参数
|
|
|
System.out.println("========== 请求参数 ==========");
|
|
|
@@ -48,7 +55,7 @@ class TencentAdsAdgroupCreateTest {
|
|
|
|
|
|
// 调用创建广告接口
|
|
|
System.out.println("正在调用腾讯广告创建API...");
|
|
|
- AdgroupsAddResponseData response = adgroupService.createAdgroup(TEST_ACCOUNT_ID, request);
|
|
|
+ AdgroupsAddResponseData response = adgroupService.createAdgroup(ORG_ACCOUNT_ID, TEST_PHONE, request);
|
|
|
|
|
|
// 输出响应结果
|
|
|
System.out.println("\n========== API返回结果 ==========");
|
|
|
@@ -76,46 +83,51 @@ class TencentAdsAdgroupCreateTest {
|
|
|
/**
|
|
|
* 构建测试请求对象
|
|
|
*/
|
|
|
- private AdgroupsAddRequest buildTestRequest() {
|
|
|
+ private AdgroupsAddRequest buildTestRequest(Long accountId) {
|
|
|
AdgroupsAddRequest request = new AdgroupsAddRequest();
|
|
|
|
|
|
// 基础字段
|
|
|
request.setAdgroupName("测试ROI-0204" + System.currentTimeMillis());
|
|
|
- request.setMarketingGoal(MarketingGoal.USER_GROWTH);
|
|
|
+ request.setAccountId(accountId);
|
|
|
+ request.setMarketingGoal(MarketingGoal.LEAD_RETENTION);
|
|
|
request.setMarketingCarrierType(MarketingCarrierType.JUMP_PAGE);
|
|
|
+ MarketingAssetOuterSpec outerSpec = new MarketingAssetOuterSpec();
|
|
|
+ outerSpec.setMarketingTargetType(MarketingTargetType.WECHAT_WORK);
|
|
|
+ outerSpec.setMarketingAssetOuterId("wp7eXwDAAAC2oIBdHTa0-QV8KNGDd3mA");
|
|
|
+ request.setMarketingAssetOuterSpec(outerSpec);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
// 投放时间
|
|
|
- request.setBeginDate("2026-02-04");
|
|
|
- request.setEndDate("2026-02-05");
|
|
|
+ request.setBeginDate("2026-02-05");
|
|
|
+ request.setEndDate("2026-02-06");
|
|
|
|
|
|
// 优化目标
|
|
|
- request.setOptimizationGoal(OptimizationGoal.APP_REGISTER);
|
|
|
+ request.setOptimizationGoal(OptimizationGoal.PAGE_SCAN_CODE);
|
|
|
|
|
|
// 时间序列(全部1表示24小时投放,共7天*48个半小时=336位)
|
|
|
request.setTimeSeries("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
|
|
|
|
|
|
// 投放站点
|
|
|
List<String> siteSet = new ArrayList<>();
|
|
|
- siteSet.add("SITE_SET_SEARCH_SCENE");
|
|
|
siteSet.add("SITE_SET_MOBILE_UNION");
|
|
|
siteSet.add("SITE_SET_WECHAT");
|
|
|
- siteSet.add("SITE_SET_KANDIAN");
|
|
|
- siteSet.add("SITE_SET_QQ_MUSIC_GAME");
|
|
|
- siteSet.add("SITE_SET_TENCENT_NEWS");
|
|
|
+ siteSet.add("SITE_SET_WECHAT_PLUGIN");
|
|
|
siteSet.add("SITE_SET_TENCENT_VIDEO");
|
|
|
+ siteSet.add("SITE_SET_SEARCH_SCENE");
|
|
|
+
|
|
|
request.setSiteSet(siteSet);
|
|
|
|
|
|
// 出价金额(单位:分)
|
|
|
request.setBidAmount(100L);
|
|
|
|
|
|
// 日预算(单位:分)
|
|
|
- request.setDailyBudget(1000L);
|
|
|
-
|
|
|
- // 转化ID
|
|
|
- request.setConversionId(74719216L);
|
|
|
-
|
|
|
+ request.setDailyBudget(10000L);
|
|
|
+
|
|
|
// 出价模式
|
|
|
request.setBidMode(BidMode.OCPM);
|
|
|
+
|
|
|
+ request.setConversionId(67676141L);
|
|
|
|
|
|
// 自动衍生创意
|
|
|
request.setAutoDerivedCreativeEnabled(false);
|
|
|
@@ -168,28 +180,16 @@ class TencentAdsAdgroupCreateTest {
|
|
|
conversionBehaviorList.add("OPTIMIZATIONGOAL_PAGE_SCAN_CODE");
|
|
|
excludedConverted.setConversionBehaviorList(conversionBehaviorList);
|
|
|
|
|
|
- excludedConverted.setExcludedDay(ExcludedDay.valueOf("EXCLUDED_DAY_ONE_MONTH"));
|
|
|
+ excludedConverted.setExcludedDay(ExcludedDay.ONE_MONTH);
|
|
|
targeting.setExcludedConvertedAudience(excludedConverted);
|
|
|
|
|
|
// 排除自定义人群
|
|
|
List<Long> excludedCustomAudience = new ArrayList<>();
|
|
|
- excludedCustomAudience.add(43712084L);
|
|
|
- excludedCustomAudience.add(44107982L);
|
|
|
excludedCustomAudience.add(44106830L);
|
|
|
- excludedCustomAudience.add(44241932L);
|
|
|
+ excludedCustomAudience.add(44107982L);
|
|
|
+ excludedCustomAudience.add(43712084L);
|
|
|
targeting.setExcludedCustomAudience(excludedCustomAudience);
|
|
|
|
|
|
return targeting;
|
|
|
}
|
|
|
-
|
|
|
- @Test
|
|
|
- @DisplayName("打印测试数据JSON")
|
|
|
- void printTestDataJson() {
|
|
|
- AdgroupsAddRequest request = buildTestRequest();
|
|
|
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
|
- String json = gson.toJson(request);
|
|
|
- System.out.println("\n========== 测试数据JSON ==========");
|
|
|
- System.out.println(json);
|
|
|
- System.out.println("========================================\n");
|
|
|
- }
|
|
|
}
|