Search in sources :

Example 16 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class CustomNamespaceAttributeConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    Process process = model.getMainProcess();
    assertNotNull(process.getAttributes());
    assertEquals(1, process.getAttributes().size());
    List<ExtensionAttribute> attributes = process.getAttributes().get("version");
    assertNotNull(attributes);
    assertEquals(1, attributes.size());
    ExtensionAttribute attribute = attributes.get(0);
    //custom:version = "9"
    assertNotNull(attribute);
    assertEquals("http://custom.org/bpmn", attribute.getNamespace());
    assertEquals("custom", attribute.getNamespacePrefix());
    assertEquals("version", attribute.getName());
    assertEquals("9", attribute.getValue());
    FlowElement flowElement = model.getMainProcess().getFlowElement("usertask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("usertask", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("usertask", userTask.getId());
    assertEquals("User Task", userTask.getName());
    Map<String, List<ExtensionAttribute>> attributesMap = userTask.getAttributes();
    assertNotNull(attributesMap);
    assertEquals(2, attributesMap.size());
    attributes = attributesMap.get("id");
    assertNotNull(attributes);
    assertEquals(1, attributes.size());
    ExtensionAttribute a = attributes.get(0);
    assertNotNull(a);
    assertEquals("id", a.getName());
    assertEquals("test", a.getValue());
    assertEquals("custom2", a.getNamespacePrefix());
    assertEquals("http://custom2.org/bpmn", a.getNamespace());
    attributes = attributesMap.get("attr");
    assertNotNull(attributes);
    assertEquals(1, attributes.size());
    a = attributes.get(0);
    assertNotNull(a);
    assertEquals("attr", a.getName());
    assertEquals("attrValue", a.getValue());
    assertEquals("custom2", a.getNamespacePrefix());
    assertEquals("http://custom2.org/bpmn", a.getNamespace());
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask) Process(org.activiti.bpmn.model.Process) List(java.util.List) ExtensionAttribute(org.activiti.bpmn.model.ExtensionAttribute)

Example 17 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class DataObjectConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());
    // verify the main process data objects
    List<ValuedDataObject> dataObjects = model.getMainProcess().getDataObjects();
    assertEquals(7, dataObjects.size());
    Map<String, ValuedDataObject> objectMap = new HashMap<String, ValuedDataObject>();
    for (ValuedDataObject valueObj : dataObjects) {
        objectMap.put(valueObj.getId(), valueObj);
    }
    ValuedDataObject dataObj = objectMap.get("dObj1");
    assertEquals("dObj1", dataObj.getId());
    assertEquals("StringTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj2");
    assertEquals("BooleanTest", dataObj.getName());
    assertEquals("xsd:boolean", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj3");
    assertEquals("DateTest", dataObj.getName());
    assertEquals("xsd:datetime", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj4");
    assertEquals("DoubleTest", dataObj.getName());
    assertEquals("xsd:double", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj5");
    assertEquals("IntegerTest", dataObj.getName());
    assertEquals("xsd:int", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj6");
    assertEquals("LongTest", dataObj.getName());
    assertEquals("xsd:long", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObjWithoutType");
    assertEquals("UnknownTypeTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("kermit", userTask.getAssignee());
    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertEquals(11, subProcess.getFlowElements().size());
    // verify the sub process data objects
    dataObjects = subProcess.getDataObjects();
    assertEquals(6, dataObjects.size());
    objectMap = new HashMap<String, ValuedDataObject>();
    for (ValuedDataObject valueObj : dataObjects) {
        objectMap.put(valueObj.getId(), valueObj);
    }
    dataObj = objectMap.get("dObj7");
    assertEquals("dObj7", dataObj.getId());
    assertEquals("StringSubTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj8");
    assertEquals("dObj8", dataObj.getId());
    assertEquals("BooleanSubTest", dataObj.getName());
    assertEquals("xsd:boolean", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj9");
    assertEquals("dObj9", dataObj.getId());
    assertEquals("DateSubTest", dataObj.getName());
    assertEquals("xsd:datetime", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj10");
    assertEquals("dObj10", dataObj.getId());
    assertEquals("DoubleSubTest", dataObj.getName());
    assertEquals("xsd:double", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj11");
    assertEquals("dObj11", dataObj.getId());
    assertEquals("IntegerSubTest", dataObj.getName());
    assertEquals("xsd:int", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj12");
    assertEquals("dObj12", dataObj.getId());
    assertEquals("LongSubTest", dataObj.getName());
    assertEquals("xsd:long", dataObj.getItemSubjectRef().getStructureRef());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) HashMap(java.util.HashMap) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask)

Example 18 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class InCompleteSignalConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("task");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("task", flowElement.getId());
    ProcessValidator processValidator = new ProcessValidatorFactory().createDefaultProcessValidator();
    List<ValidationError> errors = processValidator.validate(model);
    assertNotNull(errors);
    assertEquals(2, errors.size());
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) ProcessValidatorFactory(org.activiti.validation.ProcessValidatorFactory) UserTask(org.activiti.bpmn.model.UserTask) ValidationError(org.activiti.validation.ValidationError) ProcessValidator(org.activiti.validation.ProcessValidator)

Example 19 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class ScopedConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("outerSubProcess");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("outerSubProcess", flowElement.getId());
    SubProcess outerSubProcess = (SubProcess) flowElement;
    List<BoundaryEvent> eventList = outerSubProcess.getBoundaryEvents();
    assertEquals(1, eventList.size());
    BoundaryEvent boundaryEvent = eventList.get(0);
    assertEquals("outerBoundaryEvent", boundaryEvent.getId());
    FlowElement subElement = outerSubProcess.getFlowElement("innerSubProcess");
    assertNotNull(subElement);
    assertTrue(subElement instanceof SubProcess);
    assertEquals("innerSubProcess", subElement.getId());
    SubProcess innerSubProcess = (SubProcess) subElement;
    eventList = innerSubProcess.getBoundaryEvents();
    assertEquals(1, eventList.size());
    boundaryEvent = eventList.get(0);
    assertEquals("innerBoundaryEvent", boundaryEvent.getId());
    FlowElement taskElement = innerSubProcess.getFlowElement("usertask");
    assertNotNull(taskElement);
    assertTrue(taskElement instanceof UserTask);
    UserTask userTask = (UserTask) taskElement;
    assertEquals("usertask", userTask.getId());
    eventList = userTask.getBoundaryEvents();
    assertEquals(1, eventList.size());
    boundaryEvent = eventList.get(0);
    assertEquals("taskBoundaryEvent", boundaryEvent.getId());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask)

Example 20 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class EventJavaTest method testStartEventWithExecutionListener.

public void testStartEventWithExecutionListener() throws Exception {
    BpmnModel bpmnModel = new BpmnModel();
    Process process = new Process();
    process.setId("simpleProcess");
    process.setName("Very simple process");
    bpmnModel.getProcesses().add(process);
    StartEvent startEvent = new StartEvent();
    startEvent.setId("startEvent1");
    TimerEventDefinition timerDef = new TimerEventDefinition();
    timerDef.setTimeDuration("PT5M");
    startEvent.getEventDefinitions().add(timerDef);
    ActivitiListener listener = new ActivitiListener();
    listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    listener.setImplementation("${test}");
    listener.setEvent("end");
    startEvent.getExecutionListeners().add(listener);
    process.addFlowElement(startEvent);
    UserTask task = new UserTask();
    task.setId("reviewTask");
    task.setAssignee("kermit");
    process.addFlowElement(task);
    SequenceFlow flow1 = new SequenceFlow();
    flow1.setId("flow1");
    flow1.setSourceRef("startEvent1");
    flow1.setTargetRef("reviewTask");
    process.addFlowElement(flow1);
    EndEvent endEvent = new EndEvent();
    endEvent.setId("endEvent1");
    process.addFlowElement(endEvent);
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml)));
    Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
    repositoryService.deleteDeployment(deployment.getId());
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) UserTask(org.activiti.bpmn.model.UserTask) Deployment(org.activiti.engine.repository.Deployment) Process(org.activiti.bpmn.model.Process) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) ByteArrayInputStream(java.io.ByteArrayInputStream) StartEvent(org.activiti.bpmn.model.StartEvent) EndEvent(org.activiti.bpmn.model.EndEvent) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Aggregations

UserTask (org.activiti.bpmn.model.UserTask)48 FlowElement (org.activiti.bpmn.model.FlowElement)25 StartEvent (org.activiti.bpmn.model.StartEvent)18 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)11 SubProcess (org.activiti.bpmn.model.SubProcess)11 FormProperty (org.activiti.bpmn.model.FormProperty)7 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)6 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)6 EndEvent (org.activiti.bpmn.model.EndEvent)6 HashMap (java.util.HashMap)5 BpmnModel (org.activiti.bpmn.model.BpmnModel)5 Process (org.activiti.bpmn.model.Process)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 FormValue (org.activiti.bpmn.model.FormValue)4 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)4 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)4 AlfrescoUserTask (org.activiti.bpmn.model.alfresco.AlfrescoUserTask)4 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)4 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)4 ArrayList (java.util.ArrayList)3