use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testHumanStepBasicFormField.
/**
* Test basic form-fields (text, number, date, list, ...)
*/
@Test
public void testHumanStepBasicFormField() throws Exception {
// TODO: finish test once all types are present
WorkflowDefinition definition = new WorkflowDefinition();
definition.setId("process");
HumanStepDefinition humanStep = new HumanStepDefinition();
humanStep.setId("step1");
FormDefinition form = new FormDefinition();
humanStep.setForm(form);
FormPropertyGroup group = new FormPropertyGroup();
group.setId("group");
group.setTitle("My group");
humanStep.getForm().addFormPropertyGroup(group);
// Add simple text
TextPropertyDefinition textProperty = new TextPropertyDefinition();
textProperty.setName("text");
textProperty.setMandatory(true);
group.addFormProperty(textProperty);
definition.addStep(humanStep);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
// Check content-model
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
assertNotNull(model);
M2Type type = model.getTypes().get(0);
assertNotNull(type);
// Simple text
M2Property property = getPropertyFromType("text", type);
assertEquals("d:text", property.getPropertyType());
assertEquals(Boolean.TRUE, property.getMandatory().isMandatory());
}
use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testReviewStep.
@Test
public void testReviewStep() throws Exception {
WorkflowDefinition definition = new WorkflowDefinition();
definition.setId("process");
AlfrescoReviewStepDefinition review = new AlfrescoReviewStepDefinition();
review.setName("Review");
review.setAssignmentPropertyName("bpm:people");
review.setAssignmentType(HumanStepAssignmentType.USERS);
review.setRequiredApprovalCount("1");
AlfrescoEmailStepDefinition emailStepDefinition = new AlfrescoEmailStepDefinition();
emailStepDefinition.setName("Send rejection email");
review.getRejectionSteps().add(emailStepDefinition);
definition.addStep(review);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
new File("target/repo").mkdir();
new File("target/share").mkdir();
conversionFactory.getArtifactExporter().exportArtifacts(conversion, new File("target/repo"), new File("target/share"), false);
}
use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testEmptyWorkflowDefinitionConversion.
/**
* Check if all required artifacts are created when converting an empty workflow-definition.
*/
@Test
public void testEmptyWorkflowDefinitionConversion() {
WorkflowDefinition definition = new WorkflowDefinition();
definition.setDescription("This is the description");
definition.setId("workflowdefinition");
definition.setName("My workflow definition");
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
BpmnModel bpmnModel = conversion.getBpmnModel();
assertNotNull(bpmnModel);
Process process = bpmnModel.getMainProcess();
assertNotNull(process);
assertEquals("This is the description", process.getDocumentation());
assertEquals("My workflow definition", process.getName());
assertEquals("workflowdefinition", process.getId());
// Default start-task key should be used, as no custom startform-config is present
boolean startTaskFound = false;
for (FlowElement element : process.getFlowElements()) {
if (element instanceof StartEvent) {
assertEquals("bpm:startTask", ((StartEvent) element).getFormKey());
startTaskFound = true;
}
}
assertTrue(startTaskFound);
// Check presence of content-model
M2Model contentModel = AlfrescoConversionUtil.getContentModel(conversion);
assertNotNull(contentModel);
// Check presence of form-config and default workflow-details
Module module = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
assertNotNull(module);
assertEquals(1L, module.getConfigurations().size());
Configuration config = module.getConfigurations().get(0);
assertEquals(1L, config.getForms().size());
assertEquals("activiti$workflowdefinition", config.getCondition());
assertEquals(AlfrescoConversionConstants.EVALUATOR_STRING_COMPARE, config.getEvaluator());
}
use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testConvertEmailStep.
@Test
public void testConvertEmailStep() throws Exception {
WorkflowDefinition definition = new WorkflowDefinition();
AlfrescoEmailStepDefinition emailStep = new AlfrescoEmailStepDefinition();
emailStep.setTo("fred");
emailStep.setSubject("jos");
definition.addStep(emailStep);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
// Process should contain a single service-task
ServiceTask task = null;
for (FlowElement element : conversion.getProcess().getFlowElements()) {
if (element instanceof ServiceTask) {
if (task != null) {
Assert.fail("More than one service-task found");
}
task = (ServiceTask) element;
}
}
assertNotNull(task);
assertEquals(AlfrescoConversionConstants.CLASSNAME_SCRIPT_DELEGATE, task.getImplementation());
}
use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testTransitionProperty.
@Test
public void testTransitionProperty() throws Exception {
WorkflowDefinition definition = new WorkflowDefinition();
definition.setId("process");
HumanStepDefinition humanStep = new HumanStepDefinition();
humanStep.setId("step1");
FormDefinition form = new FormDefinition();
humanStep.setForm(form);
AlfrescoTransitionsPropertyDefinition transition = new AlfrescoTransitionsPropertyDefinition();
transition.addEntry(new ListPropertyEntry("One", "One"));
transition.addEntry(new ListPropertyEntry("Two", "Two"));
humanStep.getForm().addFormProperty(transition);
definition.addStep(humanStep);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
assertEquals(1L, model.getTypes().size());
M2Type taskType = model.getTypes().get(0);
assertEquals(1L, taskType.getPropertyOverrides().size());
assertEquals("bpm:outcomePropertyName", taskType.getPropertyOverrides().get(0).getName());
assertTrue(taskType.getPropertyOverrides().get(0).getDefaultValue().contains("step1transitions"));
assertEquals(1L, taskType.getProperties().size());
assertEquals(1L, model.getConstraints().size());
}
Aggregations