use of org.activiti.workflow.simple.definition.StepDefinition in project Activiti by Activiti.
the class JsonConverterTest method testParallelConversion.
@Test
public void testParallelConversion() {
// Create definition
WorkflowDefinition workflowDefinition = new WorkflowDefinition().name("testWorkflow").description("This is a test workflow").inParallel().inList().addHumanStep("first task", "kermit").addHumanStep("second task", "kermit").endList().inList().addHumanStep("gonzo task", "gonzo").endList().endParallel();
// Write result to byte-array
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(baos);
converter.writeWorkflowDefinition(workflowDefinition, writer);
// Parse definition based on written JSON
WorkflowDefinition parsedDefinition = converter.readWorkflowDefinition(baos.toByteArray());
// Check if parsed definition matches the original one
assertEquals(workflowDefinition.getName(), parsedDefinition.getName());
assertEquals(workflowDefinition.getDescription(), parsedDefinition.getDescription());
ParallelStepsDefinition parallelDef = null;
for (StepDefinition step : parsedDefinition.getSteps()) {
if (step instanceof ParallelStepsDefinition) {
parallelDef = (ParallelStepsDefinition) step;
}
}
assertNotNull(parallelDef);
assertEquals(2, parallelDef.getStepList().size());
ListStepDefinition<ParallelStepsDefinition> listSteps = parallelDef.getStepList().get(0);
assertEquals(2, listSteps.getSteps().size());
listSteps = parallelDef.getStepList().get(1);
assertEquals(1, listSteps.getSteps().size());
}
use of org.activiti.workflow.simple.definition.StepDefinition in project Activiti by Activiti.
the class JsonConverterTest method testChoiceConversion.
@Test
public void testChoiceConversion() {
// Create definition
WorkflowDefinition workflowDefinition = new WorkflowDefinition().name("testWorkflow").description("This is a test workflow").inChoice().inList().addCondition("test", "==", "'hello'").addCondition("test2", "==", "'world'").addHumanStep("first task", "kermit").endList().inList().addHumanStep("gonzo task", "gonzo").endList().endChoice();
// Write result to byte-array
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(baos);
converter.writeWorkflowDefinition(workflowDefinition, writer);
// Parse definition based on written JSON
WorkflowDefinition parsedDefinition = converter.readWorkflowDefinition(baos.toByteArray());
// Check if parsed definition matches the original one
assertEquals(workflowDefinition.getName(), parsedDefinition.getName());
assertEquals(workflowDefinition.getDescription(), parsedDefinition.getDescription());
ChoiceStepsDefinition choiceDef = null;
for (StepDefinition step : parsedDefinition.getSteps()) {
if (step instanceof ChoiceStepsDefinition) {
choiceDef = (ChoiceStepsDefinition) step;
}
}
assertNotNull(choiceDef);
assertEquals(2, choiceDef.getStepList().size());
ListConditionStepDefinition<ChoiceStepsDefinition> listSteps = choiceDef.getStepList().get(0);
assertEquals(2, listSteps.getConditions().size());
assertEquals("test", listSteps.getConditions().get(0).getLeftOperand());
assertEquals("==", listSteps.getConditions().get(0).getOperator());
assertEquals("'hello'", listSteps.getConditions().get(0).getRightOperand());
listSteps = choiceDef.getStepList().get(1);
assertEquals(0, listSteps.getConditions().size());
}
Aggregations