Search in sources :

Example 11 with FormProperty

use of org.activiti.bpmn.model.FormProperty 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());
        }
    }
}
Also used : FormValue(org.activiti.bpmn.model.FormValue) FormProperty(org.activiti.bpmn.model.FormProperty) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UserTask(org.activiti.bpmn.model.UserTask) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

FormProperty (org.activiti.bpmn.model.FormProperty)11 FormValue (org.activiti.bpmn.model.FormValue)7 UserTask (org.activiti.bpmn.model.UserTask)7 StartEvent (org.activiti.bpmn.model.StartEvent)6 FlowElement (org.activiti.bpmn.model.FlowElement)5 ArrayList (java.util.ArrayList)4 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 BooleanPropertyDefinition (org.activiti.workflow.simple.definition.form.BooleanPropertyDefinition)2 ListPropertyDefinition (org.activiti.workflow.simple.definition.form.ListPropertyDefinition)2 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 FieldExtension (org.activiti.bpmn.model.FieldExtension)1 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)1 DatePropertyDefinition (org.activiti.workflow.simple.definition.form.DatePropertyDefinition)1 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)1