test(workflow): 补齐模块结构与接口契约验证
This commit is contained in:
@@ -0,0 +1,132 @@
|
|||||||
|
package com.bruce.workflow;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.bruce.common.domain.model.RequestResult;
|
||||||
|
import com.bruce.workflow.controller.ProjectController;
|
||||||
|
import com.bruce.workflow.controller.WorkflowDefinitionController;
|
||||||
|
import com.bruce.workflow.controller.WorkflowRunController;
|
||||||
|
import com.bruce.workflow.controller.WorkflowVersionController;
|
||||||
|
import com.bruce.workflow.dto.ProjectSaveDTO;
|
||||||
|
import com.bruce.workflow.dto.WorkflowDefinitionSaveDTO;
|
||||||
|
import com.bruce.workflow.dto.WorkflowRunCreateDTO;
|
||||||
|
import com.bruce.workflow.dto.WorkflowVersionSaveDTO;
|
||||||
|
import com.bruce.workflow.entity.StudioProject;
|
||||||
|
import com.bruce.workflow.entity.WorkflowDefinition;
|
||||||
|
import com.bruce.workflow.entity.WorkflowRun;
|
||||||
|
import com.bruce.workflow.entity.WorkflowRunStep;
|
||||||
|
import com.bruce.workflow.entity.WorkflowVersion;
|
||||||
|
import com.bruce.workflow.mapper.StudioProjectMapper;
|
||||||
|
import com.bruce.workflow.mapper.WorkflowDefinitionMapper;
|
||||||
|
import com.bruce.workflow.mapper.WorkflowRunMapper;
|
||||||
|
import com.bruce.workflow.mapper.WorkflowRunStepMapper;
|
||||||
|
import com.bruce.workflow.mapper.WorkflowVersionMapper;
|
||||||
|
import com.bruce.workflow.service.IProjectService;
|
||||||
|
import com.bruce.workflow.service.IWorkflowDefinitionService;
|
||||||
|
import com.bruce.workflow.service.IWorkflowRunService;
|
||||||
|
import com.bruce.workflow.service.IWorkflowVersionService;
|
||||||
|
import com.bruce.workflow.service.impl.ProjectServiceImpl;
|
||||||
|
import com.bruce.workflow.service.impl.WorkflowDefinitionServiceImpl;
|
||||||
|
import com.bruce.workflow.service.impl.WorkflowRunServiceImpl;
|
||||||
|
import com.bruce.workflow.service.impl.WorkflowVersionServiceImpl;
|
||||||
|
import com.bruce.workflow.vo.ProjectVO;
|
||||||
|
import com.bruce.workflow.vo.WorkflowDefinitionVO;
|
||||||
|
import com.bruce.workflow.vo.WorkflowRunVO;
|
||||||
|
import com.bruce.workflow.vo.WorkflowVersionVO;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
class WorkflowComponentStructureTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void workflowComponentsShouldReuseMybatisPlusBaseTypes() {
|
||||||
|
assertTrue(BaseMapper.class.isAssignableFrom(StudioProjectMapper.class));
|
||||||
|
assertTrue(BaseMapper.class.isAssignableFrom(WorkflowDefinitionMapper.class));
|
||||||
|
assertTrue(BaseMapper.class.isAssignableFrom(WorkflowVersionMapper.class));
|
||||||
|
assertTrue(BaseMapper.class.isAssignableFrom(WorkflowRunMapper.class));
|
||||||
|
assertTrue(BaseMapper.class.isAssignableFrom(WorkflowRunStepMapper.class));
|
||||||
|
|
||||||
|
assertTrue(IService.class.isAssignableFrom(IProjectService.class));
|
||||||
|
assertTrue(IService.class.isAssignableFrom(IWorkflowDefinitionService.class));
|
||||||
|
assertTrue(IService.class.isAssignableFrom(IWorkflowVersionService.class));
|
||||||
|
assertTrue(IService.class.isAssignableFrom(IWorkflowRunService.class));
|
||||||
|
|
||||||
|
assertTrue(ServiceImpl.class.isAssignableFrom(ProjectServiceImpl.class));
|
||||||
|
assertTrue(ServiceImpl.class.isAssignableFrom(WorkflowDefinitionServiceImpl.class));
|
||||||
|
assertTrue(ServiceImpl.class.isAssignableFrom(WorkflowVersionServiceImpl.class));
|
||||||
|
assertTrue(ServiceImpl.class.isAssignableFrom(WorkflowRunServiceImpl.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void workflowControllersShouldExposeRequestResultMethods() throws NoSuchMethodException {
|
||||||
|
Method projectListMethod = ProjectController.class.getMethod("list");
|
||||||
|
Method projectDetailMethod = ProjectController.class.getMethod("detail", Long.class);
|
||||||
|
Method projectSaveMethod = ProjectController.class.getMethod("save", ProjectSaveDTO.class);
|
||||||
|
|
||||||
|
Method definitionListMethod = WorkflowDefinitionController.class.getMethod("list", Long.class);
|
||||||
|
Method definitionDetailMethod = WorkflowDefinitionController.class.getMethod("detail", Long.class);
|
||||||
|
Method definitionSaveMethod = WorkflowDefinitionController.class.getMethod("save", WorkflowDefinitionSaveDTO.class);
|
||||||
|
|
||||||
|
Method versionListMethod = WorkflowVersionController.class.getMethod("list", Long.class);
|
||||||
|
Method versionPublishMethod = WorkflowVersionController.class.getMethod("publish", WorkflowVersionSaveDTO.class);
|
||||||
|
|
||||||
|
Method runCreateMethod = WorkflowRunController.class.getMethod("create", WorkflowRunCreateDTO.class);
|
||||||
|
Method runListMethod = WorkflowRunController.class.getMethod("list", Long.class);
|
||||||
|
|
||||||
|
assertEquals(RequestResult.class, projectListMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, projectDetailMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, projectSaveMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, definitionListMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, definitionDetailMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, definitionSaveMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, versionListMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, versionPublishMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, runCreateMethod.getReturnType());
|
||||||
|
assertEquals(RequestResult.class, runListMethod.getReturnType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void workflowServicesShouldExposeStructuredResults() throws NoSuchMethodException {
|
||||||
|
Method projectListMethod = IProjectService.class.getMethod("listProjects");
|
||||||
|
Method projectDetailMethod = IProjectService.class.getMethod("getProject", Long.class);
|
||||||
|
Method projectSaveMethod = IProjectService.class.getMethod("saveProject", ProjectSaveDTO.class);
|
||||||
|
|
||||||
|
Method definitionListMethod = IWorkflowDefinitionService.class.getMethod("listDefinitions");
|
||||||
|
Method definitionByProjectMethod = IWorkflowDefinitionService.class.getMethod("listByProjectId", Long.class);
|
||||||
|
Method definitionDetailMethod = IWorkflowDefinitionService.class.getMethod("getDefinition", Long.class);
|
||||||
|
Method definitionSaveMethod = IWorkflowDefinitionService.class.getMethod("saveDefinition", WorkflowDefinitionSaveDTO.class);
|
||||||
|
|
||||||
|
Method versionListMethod = IWorkflowVersionService.class.getMethod("listByWorkflowId", Long.class);
|
||||||
|
Method versionPublishMethod = IWorkflowVersionService.class.getMethod("publishVersion", WorkflowVersionSaveDTO.class);
|
||||||
|
|
||||||
|
Method runCreateMethod = IWorkflowRunService.class.getMethod("createRun", WorkflowRunCreateDTO.class);
|
||||||
|
Method runListMethod = IWorkflowRunService.class.getMethod("listRecentByWorkflowId", Long.class);
|
||||||
|
|
||||||
|
assertEquals(List.class, projectListMethod.getReturnType());
|
||||||
|
assertEquals(ProjectVO.class, projectDetailMethod.getReturnType());
|
||||||
|
assertEquals(boolean.class, projectSaveMethod.getReturnType());
|
||||||
|
assertEquals(List.class, definitionListMethod.getReturnType());
|
||||||
|
assertEquals(List.class, definitionByProjectMethod.getReturnType());
|
||||||
|
assertEquals(WorkflowDefinitionVO.class, definitionDetailMethod.getReturnType());
|
||||||
|
assertEquals(boolean.class, definitionSaveMethod.getReturnType());
|
||||||
|
assertEquals(List.class, versionListMethod.getReturnType());
|
||||||
|
assertEquals(boolean.class, versionPublishMethod.getReturnType());
|
||||||
|
assertEquals(boolean.class, runCreateMethod.getReturnType());
|
||||||
|
assertEquals(List.class, runListMethod.getReturnType());
|
||||||
|
assertEquals(ProjectVO.class, ProjectVO.class);
|
||||||
|
assertEquals(WorkflowDefinitionVO.class, WorkflowDefinitionVO.class);
|
||||||
|
assertEquals(WorkflowVersionVO.class, WorkflowVersionVO.class);
|
||||||
|
assertEquals(WorkflowRunVO.class, WorkflowRunVO.class);
|
||||||
|
assertEquals(StudioProject.class, StudioProject.class);
|
||||||
|
assertEquals(WorkflowDefinition.class, WorkflowDefinition.class);
|
||||||
|
assertEquals(WorkflowVersion.class, WorkflowVersion.class);
|
||||||
|
assertEquals(WorkflowRun.class, WorkflowRun.class);
|
||||||
|
assertEquals(WorkflowRunStep.class, WorkflowRunStep.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user