use of org.camunda.bpm.engine.form.StartFormData in project camunda-bpm-platform by camunda.
the class FormPropertyDefaultValueTest method testStartFormDefaultValue.
@Deployment
public void testStartFormDefaultValue() throws Exception {
String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("FormPropertyDefaultValueTest.testDefaultValue").latestVersion().singleResult().getId();
StartFormData startForm = formService.getStartFormData(processDefinitionId);
List<FormProperty> formProperties = startForm.getFormProperties();
assertEquals(4, formProperties.size());
for (FormProperty prop : formProperties) {
if ("booleanProperty".equals(prop.getId())) {
assertEquals("true", prop.getValue());
} else if ("stringProperty".equals(prop.getId())) {
assertEquals("someString", prop.getValue());
} else if ("longProperty".equals(prop.getId())) {
assertEquals("42", prop.getValue());
} else if ("longExpressionProperty".equals(prop.getId())) {
assertEquals("23", prop.getValue());
} else {
assertTrue("Invalid form property: " + prop.getId(), false);
}
}
// Override 2 properties. The others should pe posted as the default-value
Map<String, String> formDataUpdate = new HashMap<String, String>();
formDataUpdate.put("longExpressionProperty", "1");
formDataUpdate.put("booleanProperty", "false");
ProcessInstance processInstance = formService.submitStartFormData(processDefinitionId, formDataUpdate);
assertEquals(false, runtimeService.getVariable(processInstance.getId(), "booleanProperty"));
assertEquals("someString", runtimeService.getVariable(processInstance.getId(), "stringProperty"));
assertEquals(42L, runtimeService.getVariable(processInstance.getId(), "longProperty"));
assertEquals(1L, runtimeService.getVariable(processInstance.getId(), "longExpressionProperty"));
}
use of org.camunda.bpm.engine.form.StartFormData 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);
}
use of org.camunda.bpm.engine.form.StartFormData 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);
}
use of org.camunda.bpm.engine.form.StartFormData in project camunda-bpm-platform by camunda.
the class FormAuthorizationTest method testGetStartFormData.
public void testGetStartFormData() {
// given
String processDefinitionId = selectProcessDefinitionByKey(FORM_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, FORM_PROCESS_KEY, userId, READ);
// when
StartFormData startFormData = formService.getStartFormData(processDefinitionId);
// then
assertNotNull(startFormData);
assertEquals("deployment:org/camunda/bpm/engine/test/api/form/start.form", startFormData.getFormKey());
}
Aggregations