@BeforeClass public static void setup() throws MalformedURLException { testWrkInst = new WorkflowInstance(); testWrkFlw = new Workflow(); testTask = new WorkflowTask(); testCond = new WorkflowCondition(); Metadata sharedContext = new Metadata(); // to check if the path already exists and to delete if it does exist if (new File(catalogPath).exists()) { try { FileUtils.deleteDirectory(new File(catalogPath)); } catch (IOException e) { fail(e.getMessage()); } } repo = new LuceneWorkflowInstanceRepository(catalogPath, stdPgSz); testWrkFlw.setName("test.getMetadataWorkflow"); testWrkFlw.setId("test.id"); List tasks = new Vector(); List conds = new Vector(); testCond.setConditionId("test.cond.id"); testCond.setConditionInstanceClassName("test.class"); testCond.setConditionName("test.cond.name"); testCond.setOrder(1); conds.add(testCond); testTask.setTaskConfig(new WorkflowTaskConfiguration()); testTask.setTaskId("test.task.id"); testTask.setConditions(conds); testTask.setOrder(1); testTask.setTaskInstanceClassName("test.class"); testTask.setTaskName("test.task.name"); tasks.add(testTask); testWrkFlw.setTasks(tasks); testWrkInst.setCurrentTaskId("test.task"); testWrkInst.setStatus("STARTED"); testWrkInst.setWorkflow(testWrkFlw); sharedContext.addMetadata("key1", "val1"); sharedContext.addMetadata("key1", "val2"); sharedContext.addMetadata("key1", "val3"); sharedContext.addMetadata("key2", "val4"); sharedContext.addMetadata("key2", "val5"); testWrkInst.setSharedContext(sharedContext); startXmlRpcWorkflowManager(); startWorkflow(); fmc = new XmlRpcWorkflowManagerClient(new URL("http://localhost:" + WM_PORT)); }
@Test public void testAddTask() throws RepositoryException { DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds); WorkflowTask t = new WorkflowTask(); t.setTaskName("Manual"); t.setTaskId("50"); t.setPreConditions(Collections.EMPTY_LIST); t.setPostConditions(Collections.EMPTY_LIST); String workflow = repo.addTask(t); assertThat(workflow, notNullValue()); assertThat(workflow, equalTo("3")); // TODO GET TASK BACK }