From 348a0ff02a9efadc6427ab86c3b68f576e53a236 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Mon, 20 Mar 2023 21:50:53 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E5=A4=8D=20code=20view=20?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/framework/tenant/core/job/TenantJobTest.java | 7 +++++-- .../iocoder/yudao/framework/tenant/core/job/TestJob.java | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJobTest.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJobTest.java index 9b1c6cf235..8e23338bb4 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJobTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJobTest.java @@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService; import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; import com.google.common.collect.Lists; import org.junit.jupiter.api.Test; +import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.Spy; import java.util.List; @@ -18,7 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * @author gaibu */ public class TenantJobTest extends BaseMockitoUnitTest { - @Spy + + @Mock TenantFrameworkService tenantFrameworkService; @Test @@ -31,8 +32,10 @@ public class TenantJobTest extends BaseMockitoUnitTest { TestJob testJob = new TestJob(); // 创建任务装饰器 TenantJobHandlerDecorator tenantJobHandlerDecorator = new TenantJobHandlerDecorator(tenantFrameworkService, testJob); + // 执行任务 tenantJobHandlerDecorator.execute(null); + // 断言返回值 assertEquals(testJob.getTenantIds(), tenantIds); } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TestJob.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TestJob.java index a4de61dbc6..bad1cb3045 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TestJob.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TestJob.java @@ -11,6 +11,7 @@ import java.util.concurrent.CopyOnWriteArrayList; @Component @TenantJob // 标记多租户 public class TestJob implements JobHandler { + private final List tenantIds = new CopyOnWriteArrayList<>(); @Override