From 2d0ba8e42a271bf3fff1278d733865cde2c26e0e Mon Sep 17 00:00:00 2001
From: tianfeng <769204422@qq.com>
Date: Wed, 27 Aug 2025 08:52:37 +0000
Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=EF=BC=8Ctest=E6=96=B0=E5=A2=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
rc-dependencies/pom.xml | 2 +-
.../other-application/pom.xml | 6 +-
.../command/team/query/TeamBillQryExe.java | 2 +-
.../listener/team/TeamBillSettleListener.java | 7 +
.../src/test/java/TeamMonthBillTest.java | 39 ++++
.../src/test/resources/application-local.yml | 22 +++
.../src/test/resources/application.yml | 40 +++++
.../src/test/resources/bootstrap.yml | 49 +++++
.../src/test/resources/logback-spring.xml | 148 +++++++++++++++
.../src/test/resources/tx-trace.xml | 168 ++++++++++++++++++
10 files changed, 480 insertions(+), 3 deletions(-)
create mode 100644 rc-service/rc-service-other/other-start/src/test/java/TeamMonthBillTest.java
create mode 100644 rc-service/rc-service-other/other-start/src/test/resources/application-local.yml
create mode 100644 rc-service/rc-service-other/other-start/src/test/resources/application.yml
create mode 100644 rc-service/rc-service-other/other-start/src/test/resources/bootstrap.yml
create mode 100644 rc-service/rc-service-other/other-start/src/test/resources/logback-spring.xml
create mode 100644 rc-service/rc-service-other/other-start/src/test/resources/tx-trace.xml
diff --git a/rc-dependencies/pom.xml b/rc-dependencies/pom.xml
index 7de1d8ae..6a2ec6c8 100644
--- a/rc-dependencies/pom.xml
+++ b/rc-dependencies/pom.xml
@@ -14,7 +14,7 @@
1.0.0-local
local
- 75ec24ef-edb0-4605-a8c5-7fb03c3eef8d
+ f7a8594e-090c-4830-a3ad-b5c0f9afcc07
true
diff --git a/rc-service/rc-service-other/other-application/pom.xml b/rc-service/rc-service-other/other-application/pom.xml
index 022f51eb..c54b5320 100644
--- a/rc-service/rc-service-other/other-application/pom.xml
+++ b/rc-service/rc-service-other/other-application/pom.xml
@@ -42,7 +42,11 @@
telegrambots-client
8.0.0
-
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/TeamBillQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/TeamBillQryExe.java
index f7b24586..914b22f6 100644
--- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/TeamBillQryExe.java
+++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/TeamBillQryExe.java
@@ -104,7 +104,7 @@ public class TeamBillQryExe {
}
// 经产品和运营确认,如果是钻石政策并且是日结区域,显示日账单列表
- TeamPolicyManager policy = teamPolicyManagerService.getReleaseByRegionAndType(SysOriginPlatformEnum.TARAB.name(), teamBillCycles.get(0).getRegion());
+ TeamPolicyManager policy = teamPolicyManagerService.getReleaseByRegionAndType(SysOriginPlatformEnum.LIKEI.name(), teamBillCycles.get(0).getRegion());
if (Objects.isNull(policy)) {
return teamBill;
}
diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/team/TeamBillSettleListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/team/TeamBillSettleListener.java
index 58337dae..4936d65b 100644
--- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/team/TeamBillSettleListener.java
+++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/team/TeamBillSettleListener.java
@@ -128,6 +128,13 @@ public class TeamBillSettleListener implements MessageListener {
}
}
+ /**
+ * 测试使用
+ */
+ public void processBillTest(Long teamId) {
+ this.process(new TeamBillSettleEvent().setTeamId(teamId));
+ }
+
private void processBill(TeamProfile teamProfile, TeamBillCycle teamBillCycle) {
// 获取团队区域政策
TeamPolicyManager regionPolicyManager = teamPolicyManagerService.getReleaseByRegionAndType(
diff --git a/rc-service/rc-service-other/other-start/src/test/java/TeamMonthBillTest.java b/rc-service/rc-service-other/other-start/src/test/java/TeamMonthBillTest.java
new file mode 100644
index 00000000..2897299d
--- /dev/null
+++ b/rc-service/rc-service-other/other-start/src/test/java/TeamMonthBillTest.java
@@ -0,0 +1,39 @@
+import com.red.circle.OtherServiceApplication;
+import com.red.circle.other.app.listener.team.TeamBillSettleListener;
+import com.red.circle.other.app.scheduler.TeamBillTask;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+@SpringBootTest(classes = OtherServiceApplication.class)
+@RunWith(SpringRunner.class)
+public class TeamMonthBillTest {
+
+ @Autowired
+ private TeamBillTask teamBillTask;
+ @Autowired
+ private TeamBillSettleListener teamBillSettleListener;
+
+ /**
+ * 更新账单 然很发布消息
+ */
+ @Test
+ public void processTeamBill() {
+// teamBillTask.processTeamMonthBillTest();
+ }
+
+ /**
+ * listener直接处理团队账单
+ */
+ @Test
+ public void testListener() {
+ Long teamId = 1960260858980765698L;
+// teamBillSettleListener.processBillTest(teamId);
+ }
+
+}
diff --git a/rc-service/rc-service-other/other-start/src/test/resources/application-local.yml b/rc-service/rc-service-other/other-start/src/test/resources/application-local.yml
new file mode 100644
index 00000000..6b85dafa
--- /dev/null
+++ b/rc-service/rc-service-other/other-start/src/test/resources/application-local.yml
@@ -0,0 +1,22 @@
+logging:
+ level:
+ com.red.circle.*: debug
+ com.alibaba.cloud.nacos.*: debug
+
+feign:
+ gateway:
+ url: http://127.0.0.1:1100
+ wallet:
+ url: http://127.0.0.1:2000
+ other:
+ url: http://127.0.0.1:2400
+ live:
+ url: http://127.0.0.1:2500
+ console:
+ url: http://127.0.0.1:2700
+ auth:
+ url: http://127.0.0.1:1000
+ order:
+ url: http://127.0.0.1:2600
+ external:
+ url: http://127.0.0.1:3000
\ No newline at end of file
diff --git a/rc-service/rc-service-other/other-start/src/test/resources/application.yml b/rc-service/rc-service-other/other-start/src/test/resources/application.yml
new file mode 100644
index 00000000..d5917e1b
--- /dev/null
+++ b/rc-service/rc-service-other/other-start/src/test/resources/application.yml
@@ -0,0 +1,40 @@
+server:
+ port: 2400
+ shutdown: graceful
+ undertow:
+ no-request-timeout: 10000
+
+spring:
+ lifecycle:
+ timeout-per-shutdown-phase: 30s
+ main:
+ allow-bean-definition-overriding: true
+ profiles:
+ active: local
+ group:
+ local: web-framework,openfeign,mybatis-plus
+ dev: web-framework,openfeign,mybatis-plus
+ prod: web-framework,openfeign,mybatis-plus
+ servlet:
+ multipart:
+ max-file-size: 20MB
+ max-request-size: 20MB
+ enabled: true
+
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+ endpoint:
+ shutdown:
+ enabled: false
+ info:
+ enabled: true
+ health:
+ show-details: always
+ metrics:
+ web:
+ server:
+ # http.client.requests (URI tag)太多了, 超出问题
+ max-uri-tags: 500
diff --git a/rc-service/rc-service-other/other-start/src/test/resources/bootstrap.yml b/rc-service/rc-service-other/other-start/src/test/resources/bootstrap.yml
new file mode 100644
index 00000000..47fb486f
--- /dev/null
+++ b/rc-service/rc-service-other/other-start/src/test/resources/bootstrap.yml
@@ -0,0 +1,49 @@
+spring-profile.active: local
+
+spring:
+ application:
+ name: rc-service-other
+ cloud:
+ nacos:
+ username: ${NACOS_USERNAME:nacos}
+ password: ${NACOS_PASSWORD:nacos}
+ discovery:
+ server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
+ namespace: f7a8594e-090c-4830-a3ad-b5c0f9afcc07
+ group: ${spring-profile.active}
+ register-enabled: false
+ config:
+ server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
+ file-extension: yml
+ namespace: f7a8594e-090c-4830-a3ad-b5c0f9afcc07
+ group: ${spring.application.name}
+ shared-configs:
+ - data-id: application.yml
+ group: ${spring.application.name}
+ refresh: true
+ loadbalancer:
+ cache:
+ ttl: 5s
+
+ config:
+ import:
+ - optional:nacos:application.yml?refresh=true&group=rc-service-other
+ - optional:nacos:application-${spring-profile.active}.yml?refresh=true&group=rc-service-other
+ - optional:nacos:${spring.application.name}-${spring-profile.active}.yml?refresh=true&group=rc-service-other
+ - optional:nacos:rds-config.yml?group=common
+ - optional:nacos:redis-config.yml?group=common
+ - optional:nacos:mongo-config.yml?group=common
+ - optional:nacos:rocketmq.yml?group=common
+ - optional:nacos:external.yml?refresh=true&group=common
+ - optional:nacos:framework-config.yml?refresh=true&group=common
+
+logging:
+ level:
+ com:
+ alibaba:
+ cloud:
+ nacos:
+ configdata:
+ NacosConfigDataLoader: error
+ client:
+ NacosPropertySourceBuilder: error
diff --git a/rc-service/rc-service-other/other-start/src/test/resources/logback-spring.xml b/rc-service/rc-service-other/other-start/src/test/resources/logback-spring.xml
new file mode 100644
index 00000000..07afa79d
--- /dev/null
+++ b/rc-service/rc-service-other/other-start/src/test/resources/logback-spring.xml
@@ -0,0 +1,148 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${CONSOLE_LOG_PATTERN}
+
+
+
+
+
+ ${log.path}/debug.log
+
+ ${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz
+ 50MB
+ 7
+
+
+ %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n
+
+
+
+
+
+ ${log.path}/error.log
+
+ ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz
+ 50MB
+ 7
+
+
+ %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n
+
+
+ ERROR
+
+
+
+
+
+ ap-singapore.cls.tencentcs.com
+ AKIDSnx10rZK4d6NTRGtIYbPQFuLcp3CB0nR
+ c5oT2Y8nNnxzongUDlKkCVfjbLvKUXRC
+ 180afe72-b0fe-4502-bbc2-55a8a5193e78
+
+
+ 104857600
+ 60000
+ 8
+ 524288
+ 4096
+ 2000
+ 10
+ 100
+ 100
+
+
+
+ %d %-5level [%thread] %logger{0}
+
+
+
+ yyyy-MM-dd'T'HH:mmZ
+
+ Asia/Shanghai
+ {"app":"${spring.application.name}"}
+
+
+
+
+ ap-singapore.cls.tencentcs.com
+ AKIDSnx10rZK4d6NTRGtIYbPQFuLcp3CB0nR
+ c5oT2Y8nNnxzongUDlKkCVfjbLvKUXRC
+ 4d467d31-9165-42c6-b80a-2ea23ae7777e
+
+
+ 104857600
+ 60000
+ 8
+ 524288
+ 4096
+ 2000
+ 10
+ 100
+ 100
+
+
+
+ %d %-5level [%thread] %logger{0}
+
+
+
+ yyyy-MM-dd'T'HH:mmZ
+
+ Asia/Shanghai
+ {"app":"${spring.application.name}"}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/rc-service/rc-service-other/other-start/src/test/resources/tx-trace.xml b/rc-service/rc-service-other/other-start/src/test/resources/tx-trace.xml
new file mode 100644
index 00000000..5840d2c1
--- /dev/null
+++ b/rc-service/rc-service-other/other-start/src/test/resources/tx-trace.xml
@@ -0,0 +1,168 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [%thread] %-5level %logger{15}#%line %X{req.requestURI} traceId: %X{trace_id} spanId:
+ %X{span_id} %msg
+
+
+
+
+
+
+ ${log.path}/debug.log
+
+ ${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz
+ 50MB
+ 7
+
+
+
+ [%thread] %-5level %logger{15}#%line %X{req.requestURI} traceId: %X{trace_id} spanId:
+ %X{span_id} %msg
+
+
+
+
+
+
+ ${log.path}/error.log
+
+ ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz
+ 50MB
+ 7
+
+
+
+ [%thread] %-5level %logger{15}#%line %X{req.requestURI} traceId: %X{trace_id} spanId:
+ %X{span_id} %msg
+
+
+
+ ERROR
+
+
+
+
+
+ ap-singapore.cls.tencentcs.com
+ AKIDSnx10rZK4d6NTRGtIYbPQFuLcp3CB0nR
+ c5oT2Y8nNnxzongUDlKkCVfjbLvKUXRC
+ 180afe72-b0fe-4502-bbc2-55a8a5193e78
+
+
+ 104857600
+ 60000
+ 8
+ 524288
+ 4096
+ 2000
+ 10
+ 100
+ 100
+
+
+
+
+ [%thread] %-5level %logger{15}#%line %X{req.requestURI} traceId: %X{trace_id} spanId:
+ %X{span_id} %msg
+
+
+
+
+ yyyy-MM-dd'T'HH:mmZ
+
+ Asia/Shanghai
+ {"app":"${spring.application.name}"}
+
+
+
+
+ ap-singapore.cls.tencentcs.com
+ AKIDSnx10rZK4d6NTRGtIYbPQFuLcp3CB0nR
+ c5oT2Y8nNnxzongUDlKkCVfjbLvKUXRC
+ 4d467d31-9165-42c6-b80a-2ea23ae7777e
+
+
+ 104857600
+ 60000
+ 8
+ 524288
+ 4096
+ 2000
+ 10
+ 100
+ 100
+
+
+
+
+ [%thread] %-5level %logger{15}#%line %X{req.requestURI} traceId: %X{trace_id} spanId:
+ %X{span_id} %msg
+
+
+
+
+ yyyy-MM-dd'T'HH:mmZ
+
+ Asia/Shanghai
+ {"app":"${spring.application.name}"}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+