Search in sources :

Example 11 with FormField

use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.

the class FormServiceTest method testGetStartFormWithoutLabels.

@Deployment
@Test
public void testGetStartFormWithoutLabels() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    runtimeService.startProcessInstanceById(processDefinition.getId());
    // form data can be retrieved
    StartFormData formData = formService.getStartFormData(processDefinition.getId());
    List<FormField> formFields = formData.getFormFields();
    assertEquals(3, formFields.size());
    List<String> formFieldIds = new ArrayList<String>();
    for (FormField field : formFields) {
        assertNull(field.getLabel());
        formFieldIds.add(field.getId());
    }
    assertTrue(formFieldIds.containsAll(Arrays.asList("stringField", "customField", "longField")));
    // the form can be rendered
    Object startForm = formService.getRenderedStartForm(processDefinition.getId());
    assertNotNull(startForm);
}
Also used : StartFormData(org.camunda.bpm.engine.form.StartFormData) ArrayList(java.util.ArrayList) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) FormField(org.camunda.bpm.engine.form.FormField) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 12 with FormField

use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.

the class FormDataTest method testMissingFormVariables.

@Deployment
public void testMissingFormVariables() {
    // given process definition with defined form varaibles
    // when start process instance with no variables
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("date-form-property-test");
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    // then taskFormData contains form variables with null as values
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    assertNotNull(taskFormData);
    assertEquals(5, taskFormData.getFormFields().size());
    for (FormField field : taskFormData.getFormFields()) {
        assertNotNull(field);
        assertNull(field.getValue().getValue());
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) FormField(org.camunda.bpm.engine.form.FormField) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 13 with FormField

use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.

the class FormDataTest method testGetFormFieldBasicProperties.

@Deployment
public void testGetFormFieldBasicProperties() {
    runtimeService.startProcessInstanceByKey("FormDataTest.testGetFormFieldBasicProperties");
    Task task = taskService.createTaskQuery().singleResult();
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    // validate properties:
    List<FormField> formFields = taskFormData.getFormFields();
    // validate field 1
    FormField formField1 = formFields.get(0);
    assertNotNull(formField1);
    assertEquals(formField1.getId(), "formField1");
    assertEquals(formField1.getLabel(), "Form Field 1");
    assertEquals("string", formField1.getTypeName());
    assertNotNull(formField1.getType());
    // validate field 2
    FormField formField2 = formFields.get(1);
    assertNotNull(formField2);
    assertEquals(formField2.getId(), "formField2");
    assertEquals(formField2.getLabel(), "Form Field 2");
    assertEquals("boolean", formField2.getTypeName());
    assertNotNull(formField1.getType());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) FormField(org.camunda.bpm.engine.form.FormField) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with FormField

use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.

the class FormDataTest method testGetFormFieldBuiltInTypes.

@Deployment
public void testGetFormFieldBuiltInTypes() {
    runtimeService.startProcessInstanceByKey("FormDataTest.testGetFormFieldBuiltInTypes");
    Task task = taskService.createTaskQuery().singleResult();
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    // validate properties:
    List<FormField> formFields = taskFormData.getFormFields();
    // validate string field
    FormField stringField = formFields.get(0);
    assertNotNull(stringField);
    assertEquals("string", stringField.getTypeName());
    assertNotNull(stringField.getType());
    assertEquals("someString", stringField.getDefaultValue());
    // validate long field
    FormField longField = formFields.get(1);
    assertNotNull(longField);
    assertEquals("long", longField.getTypeName());
    assertNotNull(longField.getType());
    assertEquals(Long.valueOf(1l), longField.getDefaultValue());
    // validate boolean field
    FormField booleanField = formFields.get(2);
    assertNotNull(booleanField);
    assertEquals("boolean", booleanField.getTypeName());
    assertNotNull(booleanField.getType());
    assertEquals(Boolean.valueOf(true), booleanField.getDefaultValue());
    // validate date field
    FormField dateField = formFields.get(3);
    assertNotNull(dateField);
    assertEquals("date", dateField.getTypeName());
    assertNotNull(dateField.getType());
    Date dateValue = (Date) dateField.getDefaultValue();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(dateValue);
    assertEquals(10, calendar.get(Calendar.DAY_OF_MONTH));
    assertEquals(Calendar.JANUARY, calendar.get(Calendar.MONTH));
    assertEquals(2013, calendar.get(Calendar.YEAR));
    // validate enum field
    FormField enumField = formFields.get(4);
    assertNotNull(enumField);
    assertEquals("enum", enumField.getTypeName());
    assertNotNull(enumField.getType());
    EnumFormType enumFormType = (EnumFormType) enumField.getType();
    Map<String, String> values = enumFormType.getValues();
    assertEquals("A", values.get("a"));
    assertEquals("B", values.get("b"));
    assertEquals("C", values.get("c"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) Calendar(java.util.Calendar) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) FormField(org.camunda.bpm.engine.form.FormField) Date(java.util.Date) EnumFormType(org.camunda.bpm.engine.impl.form.type.EnumFormType) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

FormField (org.camunda.bpm.engine.form.FormField)14 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)8 Deployment (org.camunda.bpm.engine.test.Deployment)8 Task (org.camunda.bpm.engine.task.Task)6 ArrayList (java.util.ArrayList)4 StartFormData (org.camunda.bpm.engine.form.StartFormData)4 Test (org.junit.Test)3 FormProperty (org.camunda.bpm.engine.form.FormProperty)2 FormType (org.camunda.bpm.engine.form.FormType)2 HistoricFormField (org.camunda.bpm.engine.history.HistoricFormField)2 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)2 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 FormFieldValidationConstraint (org.camunda.bpm.engine.form.FormFieldValidationConstraint)1 EnumFormType (org.camunda.bpm.engine.impl.form.type.EnumFormType)1 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)1 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)1 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1