test: 修复 code view 存在的问题

This commit is contained in:
gaibu 2023-03-20 21:50:53 +08:00
parent b54c5eaa45
commit 348a0ff02a
2 changed files with 6 additions and 2 deletions

View File

@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.Spy;
import java.util.List; import java.util.List;
@ -18,7 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* @author gaibu * @author gaibu
*/ */
public class TenantJobTest extends BaseMockitoUnitTest { public class TenantJobTest extends BaseMockitoUnitTest {
@Spy
@Mock
TenantFrameworkService tenantFrameworkService; TenantFrameworkService tenantFrameworkService;
@Test @Test
@ -31,8 +32,10 @@ public class TenantJobTest extends BaseMockitoUnitTest {
TestJob testJob = new TestJob(); TestJob testJob = new TestJob();
// 创建任务装饰器 // 创建任务装饰器
TenantJobHandlerDecorator tenantJobHandlerDecorator = new TenantJobHandlerDecorator(tenantFrameworkService, testJob); TenantJobHandlerDecorator tenantJobHandlerDecorator = new TenantJobHandlerDecorator(tenantFrameworkService, testJob);
// 执行任务 // 执行任务
tenantJobHandlerDecorator.execute(null); tenantJobHandlerDecorator.execute(null);
// 断言返回值 // 断言返回值
assertEquals(testJob.getTenantIds(), tenantIds); assertEquals(testJob.getTenantIds(), tenantIds);
} }

View File

@ -11,6 +11,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
@Component @Component
@TenantJob // 标记多租户 @TenantJob // 标记多租户
public class TestJob implements JobHandler { public class TestJob implements JobHandler {
private final List<Long> tenantIds = new CopyOnWriteArrayList<>(); private final List<Long> tenantIds = new CopyOnWriteArrayList<>();
@Override @Override