use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class StartEventJsonConverter method convertJsonToElement.
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
StartEvent startEvent = new StartEvent();
startEvent.setInitiator(getPropertyValueAsString(PROPERTY_NONE_STARTEVENT_INITIATOR, elementNode));
String stencilId = BpmnJsonConverterUtil.getStencilId(elementNode);
if (STENCIL_EVENT_START_NONE.equals(stencilId)) {
String formKey = getPropertyValueAsString(PROPERTY_FORMKEY, elementNode);
if (StringUtils.isNotEmpty(formKey)) {
startEvent.setFormKey(formKey);
}
convertJsonToFormProperties(elementNode, startEvent);
} else if (STENCIL_EVENT_START_TIMER.equals(stencilId)) {
convertJsonToTimerDefinition(elementNode, startEvent);
} else if (STENCIL_EVENT_START_ERROR.equals(stencilId)) {
convertJsonToErrorDefinition(elementNode, startEvent);
} else if (STENCIL_EVENT_START_MESSAGE.equals(stencilId)) {
convertJsonToMessageDefinition(elementNode, startEvent);
} else if (STENCIL_EVENT_START_SIGNAL.equals(stencilId)) {
convertJsonToSignalDefinition(elementNode, startEvent);
}
return startEvent;
}
use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class StartEventConverterTest method validateModel.
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("start");
assertTrue(flowElement instanceof StartEvent);
StartEvent startEvent = (StartEvent) flowElement;
assertEquals("start", startEvent.getId());
assertEquals("startName", startEvent.getName());
assertEquals("startFormKey", startEvent.getFormKey());
assertEquals("startInitiator", startEvent.getInitiator());
assertEquals("startDoc", startEvent.getDocumentation());
List<FormProperty> formProperties = startEvent.getFormProperties();
assertEquals(2, formProperties.size());
FormProperty formProperty = formProperties.get(0);
assertEquals("startFormProp1", formProperty.getId());
assertEquals("startFormProp1", formProperty.getName());
assertEquals("string", formProperty.getType());
formProperty = formProperties.get(1);
assertEquals("startFormProp2", formProperty.getId());
assertEquals("startFormProp2", formProperty.getName());
assertEquals("boolean", formProperty.getType());
}
use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class SubProcessConverterTest method validateModel.
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
assertNotNull(flowElement);
assertTrue(flowElement instanceof StartEvent);
assertEquals("start1", flowElement.getId());
flowElement = model.getMainProcess().getFlowElement("userTask1");
assertNotNull(flowElement);
assertTrue(flowElement instanceof UserTask);
assertEquals("userTask1", flowElement.getId());
UserTask userTask = (UserTask) flowElement;
assertTrue(userTask.getCandidateUsers().size() == 1);
assertTrue(userTask.getCandidateGroups().size() == 1);
assertTrue(userTask.getFormProperties().size() == 2);
flowElement = model.getMainProcess().getFlowElement("subprocess1");
assertNotNull(flowElement);
assertTrue(flowElement instanceof SubProcess);
assertEquals("subprocess1", flowElement.getId());
SubProcess subProcess = (SubProcess) flowElement;
assertTrue(subProcess.getFlowElements().size() == 5);
flowElement = model.getMainProcess().getFlowElement("boundaryEvent1");
assertNotNull(flowElement);
assertTrue(flowElement instanceof BoundaryEvent);
assertEquals("boundaryEvent1", flowElement.getId());
BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
assertNotNull(boundaryEvent.getAttachedToRef());
assertEquals("subprocess1", boundaryEvent.getAttachedToRef().getId());
assertEquals(1, boundaryEvent.getEventDefinitions().size());
assertTrue(boundaryEvent.getEventDefinitions().get(0) instanceof TimerEventDefinition);
}
use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class UserTaskConverterTest method validateModel.
private void validateModel(BpmnModel model) {
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());
assertEquals("testKey", userTask.getFormKey());
assertEquals("40", userTask.getPriority());
assertEquals("2012-11-01", userTask.getDueDate());
assertEquals("defaultCategory", userTask.getCategory());
assertEquals("gonzo", userTask.getOwner());
assertEquals("kermit", userTask.getAssignee());
assertEquals(2, userTask.getCandidateUsers().size());
assertTrue(userTask.getCandidateUsers().contains("kermit"));
assertTrue(userTask.getCandidateUsers().contains("fozzie"));
assertEquals(2, userTask.getCandidateGroups().size());
assertTrue(userTask.getCandidateGroups().contains("management"));
assertTrue(userTask.getCandidateGroups().contains("sales"));
List<FormProperty> formProperties = userTask.getFormProperties();
assertEquals(2, formProperties.size());
FormProperty formProperty = formProperties.get(0);
assertEquals("formId", formProperty.getId());
assertEquals("formName", formProperty.getName());
assertEquals("string", formProperty.getType());
assertEquals("variable", formProperty.getVariable());
assertEquals("${expression}", formProperty.getExpression());
formProperty = formProperties.get(1);
assertEquals("formId2", formProperty.getId());
assertEquals("anotherName", formProperty.getName());
assertEquals("long", formProperty.getType());
assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
List<ActivitiListener> listeners = userTask.getTaskListeners();
assertEquals(3, listeners.size());
ActivitiListener listener = (ActivitiListener) listeners.get(0);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
assertEquals("org.test.TestClass", listener.getImplementation());
assertEquals("create", listener.getEvent());
assertEquals(2, listener.getFieldExtensions().size());
assertEquals("testField", listener.getFieldExtensions().get(0).getFieldName());
assertEquals("test", listener.getFieldExtensions().get(0).getStringValue());
listener = (ActivitiListener) listeners.get(1);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
assertEquals("${someExpression}", listener.getImplementation());
assertEquals("assignment", listener.getEvent());
listener = (ActivitiListener) listeners.get(2);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
assertEquals("${someDelegateExpression}", listener.getImplementation());
assertEquals("complete", listener.getEvent());
flowElement = model.getMainProcess().getFlowElement("start");
assertTrue(flowElement instanceof StartEvent);
StartEvent startEvent = (StartEvent) flowElement;
assertTrue(startEvent.getOutgoingFlows().size() == 1);
flowElement = model.getMainProcess().getFlowElement("flow1");
assertTrue(flowElement instanceof SequenceFlow);
SequenceFlow flow = (SequenceFlow) flowElement;
assertEquals("flow1", flow.getId());
assertNotNull(flow.getSourceRef());
assertNotNull(flow.getTargetRef());
}
use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class FormPropertiesConverterTest method validateModel.
private void validateModel(BpmnModel model) {
assertEquals("formPropertiesProcess", model.getMainProcess().getId());
assertEquals("User registration", model.getMainProcess().getName());
assertEquals(true, model.getMainProcess().isExecutable());
FlowElement startFlowElement = model.getMainProcess().getFlowElement("startNode");
assertNotNull(startFlowElement);
assertTrue(startFlowElement instanceof StartEvent);
StartEvent startEvent = (StartEvent) startFlowElement;
List<FormProperty> formProperties = startEvent.getFormProperties();
assertNotNull(formProperties);
assertEquals("Invalid form properties list: ", 8, formProperties.size());
for (FormProperty formProperty : formProperties) {
if (formProperty.getId().equals("new_property_1")) {
checkFormProperty(formProperty, "v000", true, false, false);
} else if (formProperty.getId().equals("new_property_2")) {
checkFormProperty(formProperty, "v001", true, false, true);
} else if (formProperty.getId().equals("new_property_3")) {
checkFormProperty(formProperty, "v010", true, true, false);
} else if (formProperty.getId().equals("new_property_4")) {
checkFormProperty(formProperty, "v011", true, true, true);
} else if (formProperty.getId().equals("new_property_5")) {
checkFormProperty(formProperty, "v100", true, false, false);
List<Map<String, Object>> formValues = new ArrayList<Map<String, Object>>();
for (FormValue formValue : formProperty.getFormValues()) {
Map<String, Object> formValueMap = new HashMap<String, Object>();
formValueMap.put("id", formValue.getId());
formValueMap.put("name", formValue.getName());
formValues.add(formValueMap);
}
checkFormPropertyFormValues(formValues);
} else if (formProperty.getId().equals("new_property_6")) {
checkFormProperty(formProperty, "v101", true, false, true);
} else if (formProperty.getId().equals("new_property_7")) {
checkFormProperty(formProperty, "v110", true, true, false);
} else if (formProperty.getId().equals("new_property_8")) {
checkFormProperty(formProperty, "v111", true, true, true);
} else {
fail("unexpected form property id " + formProperty.getId());
}
}
FlowElement userFlowElement = model.getMainProcess().getFlowElement("userTask");
assertNotNull(userFlowElement);
assertTrue(userFlowElement instanceof UserTask);
UserTask userTask = (UserTask) userFlowElement;
formProperties = userTask.getFormProperties();
assertNotNull(formProperties);
assertEquals("Invalid form properties list: ", 8, formProperties.size());
for (FormProperty formProperty : formProperties) {
if (formProperty.getId().equals("new_property_1")) {
checkFormProperty(formProperty, "v000", false, false, false);
} else if (formProperty.getId().equals("new_property_2")) {
checkFormProperty(formProperty, "v001", false, false, true);
} else if (formProperty.getId().equals("new_property_3")) {
checkFormProperty(formProperty, "v010", false, true, false);
} else if (formProperty.getId().equals("new_property_4")) {
checkFormProperty(formProperty, "v011", false, true, true);
} else if (formProperty.getId().equals("new_property_5")) {
checkFormProperty(formProperty, "v100", true, false, false);
List<Map<String, Object>> formValues = new ArrayList<Map<String, Object>>();
for (FormValue formValue : formProperty.getFormValues()) {
Map<String, Object> formValueMap = new HashMap<String, Object>();
formValueMap.put("id", formValue.getId());
formValueMap.put("name", formValue.getName());
formValues.add(formValueMap);
}
checkFormPropertyFormValues(formValues);
} else if (formProperty.getId().equals("new_property_6")) {
checkFormProperty(formProperty, "v101", true, false, true);
} else if (formProperty.getId().equals("new_property_7")) {
checkFormProperty(formProperty, "v110", true, true, false);
} else if (formProperty.getId().equals("new_property_8")) {
checkFormProperty(formProperty, "v111", true, true, true);
} else {
fail("unexpected form property id " + formProperty.getId());
}
}
}
Aggregations