Search in sources :

Example 26 with WorkflowDefinition

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());
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) TextPropertyDefinition(org.activiti.workflow.simple.definition.form.TextPropertyDefinition) M2Property(org.activiti.workflow.simple.alfresco.model.M2Property) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) FormPropertyGroup(org.activiti.workflow.simple.definition.form.FormPropertyGroup) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition) Test(org.junit.Test)

Example 27 with WorkflowDefinition

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);
}
Also used : AlfrescoReviewStepDefinition(org.activiti.workflow.simple.alfresco.step.AlfrescoReviewStepDefinition) WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) AlfrescoEmailStepDefinition(org.activiti.workflow.simple.alfresco.step.AlfrescoEmailStepDefinition) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) File(java.io.File) Test(org.junit.Test)

Example 28 with WorkflowDefinition

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());
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) Configuration(org.activiti.workflow.simple.alfresco.model.config.Configuration) FlowElement(org.activiti.bpmn.model.FlowElement) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) StartEvent(org.activiti.bpmn.model.StartEvent) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) Process(org.activiti.bpmn.model.Process) Module(org.activiti.workflow.simple.alfresco.model.config.Module) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Example 29 with WorkflowDefinition

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());
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) ServiceTask(org.activiti.bpmn.model.ServiceTask) AlfrescoEmailStepDefinition(org.activiti.workflow.simple.alfresco.step.AlfrescoEmailStepDefinition) FlowElement(org.activiti.bpmn.model.FlowElement) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) Test(org.junit.Test)

Example 30 with WorkflowDefinition

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());
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) ListPropertyEntry(org.activiti.workflow.simple.definition.form.ListPropertyEntry) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) AlfrescoTransitionsPropertyDefinition(org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition) Test(org.junit.Test)

Aggregations

WorkflowDefinition (org.activiti.workflow.simple.definition.WorkflowDefinition)32 Test (org.junit.Test)24 WorkflowDefinitionConversion (org.activiti.workflow.simple.converter.WorkflowDefinitionConversion)16 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)10 Task (org.activiti.engine.task.Task)7 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 TaskService (org.activiti.engine.TaskService)6 OutputStreamWriter (java.io.OutputStreamWriter)5 Process (org.activiti.bpmn.model.Process)5 Writer (java.io.Writer)4 BpmnModel (org.activiti.bpmn.model.BpmnModel)4 FlowElement (org.activiti.bpmn.model.FlowElement)4 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)4 ListStepDefinition (org.activiti.workflow.simple.definition.ListStepDefinition)4 RepositoryService (org.activiti.engine.RepositoryService)3 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)3 M2Type (org.activiti.workflow.simple.alfresco.model.M2Type)3 ListConditionStepDefinition (org.activiti.workflow.simple.definition.ListConditionStepDefinition)3 StepDefinition (org.activiti.workflow.simple.definition.StepDefinition)3