package com.jinhe.tss.cms.module; import java.io.File; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import com.jinhe.tss.cms.TxSupportTest4CMS; import com.jinhe.tss.cms.workflow.WorkFlow; import com.jinhe.tss.cms.workflow.WorkFlowAction; import com.jinhe.tss.cms.workflow.WorkFlowManager; import com.jinhe.tss.cms.workflow.WorkFlowNode; import com.jinhe.tss.cms.workflow.WorkFlowService; import com.jinhe.tss.cms.workflow.WorkFlowNode.WorkerFlowButton; import com.jinhe.tss.core.cachepool.CacheableKey; import com.jinhe.tss.core.cachepool.proxy.profier.CGLIBProfiler; import com.jinhe.tss.core.util.URLUtil; /** * 文章工作流相关模块的单元测试。 */ public class WorkFlowModuleTest extends TxSupportTest4CMS { WorkFlowAction workFlowAction; @Autowired private WorkFlowService workFlowService; public void setUp() throws Exception { super.setUp(); workFlowAction = (WorkFlowAction) new CGLIBProfiler().getProxy(WorkFlowAction.class); workFlowAction.setWorkFlowService(workFlowService); } public void testWorkFlowModule() { workFlowAction.getWorkFlowModel(); String path = URLUtil.getResourceFileUrl("workflow/WorkflowTemplate.xml").getPath(); File file = new File(path); workFlowAction.setFile(file ); workFlowAction.setName("测试工作流"); workFlowAction.importWorkFlow(); workFlowAction.viewAll(); workFlowAction.setCode(11); workFlowAction.delete(); workFlowAction.viewAll(); WorkFlowManager wfManager = WorkFlowManager.getInstance(); List<CacheableKey> list = wfManager.getWorkFlowCodes(); assertEquals(list.size(), 3); String[] codeNames = wfManager.getWorkFlowCodeAndNames(); assertNotNull(codeNames); for(String temp : codeNames) { log.debug(temp); } Integer workflowId = 1; WorkFlow wl = wfManager.getWorkFlow(workflowId); assertNotNull(wl); log.debug(wl); Integer status = 2; WorkFlowNode wln = wfManager.getWorkFlowNode(workflowId, status); assertNotNull(wln); log.debug(wln); String[] statusAndNames = wfManager.getFlowStepStatusAndNames(workflowId); assertNotNull(statusAndNames); for(String temp : statusAndNames) { log.debug(temp); } WorkerFlowButton pb = wfManager.getPreviewButton(workflowId, status); assertNotNull(pb); log.debug(pb); WorkerFlowButton nb = wfManager.getNextButton(workflowId, status); assertNotNull(nb); log.debug(nb); status = 3; Map<Integer, WorkerFlowButton> map = wfManager.getPreviews(workflowId, status); for(Map.Entry<Integer, WorkerFlowButton> entry : map.entrySet()) { log.debug(entry.getKey() + " = (" + entry.getValue() + ")"); } } }