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 9b1c6cf23..8e23338bb 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 a4de61dbc..bad1cb304 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