}
@Deployment(resources={"org/camunda/bpm/engine/test/api/form/FormServiceTest.startFormFields.bpmn20.xml"})
public void testGetStartFormVariables() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
VariableMap variables = formService.getStartFormVariables(processDefinition.getId());
assertEquals(4, variables.size());
assertEquals("someString", variables.get("stringField"));
assertEquals("someString", variables.getValueTyped("stringField").getValue());
assertEquals(ValueType.STRING, variables.getValueTyped("stringField").getType());
assertEquals(5l, variables.get("longField"));
assertEquals(5l, variables.getValueTyped("longField").getValue());
assertEquals(ValueType.LONG, variables.getValueTyped("longField").getType());
assertNull(variables.get("customField"));
assertNull(variables.getValueTyped("customField").getValue());
assertEquals(ValueType.STRING, variables.getValueTyped("customField").getType());
assertNotNull(variables.get("dateField"));
assertEquals(variables.get("dateField"), variables.getValueTyped("dateField").getValue());
assertEquals(ValueType.STRING, variables.getValueTyped("dateField").getType());
AbstractFormFieldType dateFormType = processEngineConfiguration.getFormTypes().getFormType("date");
Date dateValue = (Date) dateFormType.convertToModelValue(variables.getValueTyped("dateField")).getValue();
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));
// get restricted set of variables:
variables = formService.getStartFormVariables(processDefinition.getId(), Arrays.asList("stringField"), true);
assertEquals(1, variables.size());
assertEquals("someString", variables.get("stringField"));
assertEquals("someString", variables.getValueTyped("stringField").getValue());
assertEquals(ValueType.STRING, variables.getValueTyped("stringField").getType());
// request non-existing variable
variables = formService.getStartFormVariables(processDefinition.getId(), Arrays.asList("non-existing!"), true);
assertEquals(0, variables.size());
// null => all
variables = formService.getStartFormVariables(processDefinition.getId(), null, true);
assertEquals(4, variables.size());
}