Search in sources :

Example 11 with FormProperty

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

the class FormServiceTest method testFormPropertyDetails.

@SuppressWarnings("unchecked")
@Deployment
@Test
public void testFormPropertyDetails() {
    String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    StartFormData startFormData = formService.getStartFormData(procDefId);
    FormProperty property = startFormData.getFormProperties().get(0);
    assertEquals("speaker", property.getId());
    assertNull(property.getValue());
    assertTrue(property.isReadable());
    assertTrue(property.isWritable());
    assertFalse(property.isRequired());
    assertEquals("string", property.getType().getName());
    property = startFormData.getFormProperties().get(1);
    assertEquals("start", property.getId());
    assertNull(property.getValue());
    assertTrue(property.isReadable());
    assertTrue(property.isWritable());
    assertFalse(property.isRequired());
    assertEquals("date", property.getType().getName());
    assertEquals("dd-MMM-yyyy", property.getType().getInformation("datePattern"));
    property = startFormData.getFormProperties().get(2);
    assertEquals("direction", property.getId());
    assertNull(property.getValue());
    assertTrue(property.isReadable());
    assertTrue(property.isWritable());
    assertFalse(property.isRequired());
    assertEquals("enum", property.getType().getName());
    Map<String, String> values = (Map<String, String>) property.getType().getInformation("values");
    Map<String, String> expectedValues = new LinkedHashMap<String, String>();
    expectedValues.put("left", "Go Left");
    expectedValues.put("right", "Go Right");
    expectedValues.put("up", "Go Up");
    expectedValues.put("down", "Go Down");
    // ACT-1023: check if ordering is retained
    Iterator<Entry<String, String>> expectedValuesIterator = expectedValues.entrySet().iterator();
    for (Entry<String, String> entry : values.entrySet()) {
        Entry<String, String> expectedEntryAtLocation = expectedValuesIterator.next();
        assertEquals(expectedEntryAtLocation.getKey(), entry.getKey());
        assertEquals(expectedEntryAtLocation.getValue(), entry.getValue());
    }
    assertEquals(expectedValues, values);
}
Also used : Entry(java.util.Map.Entry) FormProperty(org.camunda.bpm.engine.form.FormProperty) StartFormData(org.camunda.bpm.engine.form.StartFormData) Map(java.util.Map) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

FormProperty (org.camunda.bpm.engine.form.FormProperty)11 HashMap (java.util.HashMap)6 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)5 Deployment (org.camunda.bpm.engine.test.Deployment)5 LinkedHashMap (java.util.LinkedHashMap)4 StartFormData (org.camunda.bpm.engine.form.StartFormData)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 FormField (org.camunda.bpm.engine.form.FormField)2 FormType (org.camunda.bpm.engine.form.FormType)2 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2 Task (org.camunda.bpm.engine.task.Task)2 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1