use of org.camunda.bpm.engine.form.StartFormData in project camunda-bpm-platform by camunda.
the class ProcessDefinitionRestServiceInteractionTest method testGetStartForm_shouldReturnKeyContainingTaskId.
@Test
public void testGetStartForm_shouldReturnKeyContainingTaskId() {
ProcessDefinition mockDefinition = MockProvider.createMockDefinition();
StartFormData mockStartFormData = MockProvider.createMockStartFormDataUsingFormFieldsWithoutFormKey(mockDefinition);
when(formServiceMock.getStartFormData(mockDefinition.getId())).thenReturn(mockStartFormData);
given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("key", equalTo("embedded:engine://engine/:engine/process-definition/" + mockDefinition.getId() + "/rendered-form")).body("contextPath", equalTo(MockProvider.EXAMPLE_PROCESS_APPLICATION_CONTEXT_PATH)).when().get(START_FORM_URL);
}
use of org.camunda.bpm.engine.form.StartFormData in project camunda-bpm-platform by camunda.
the class ProcessDefinitionResourceImpl method getStartForm.
@Override
public FormDto getStartForm() {
final FormService formService = engine.getFormService();
final StartFormData formData;
try {
formData = formService.getStartFormData(processDefinitionId);
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "Cannot get start form data for process definition " + processDefinitionId);
}
FormDto dto = FormDto.fromFormData(formData);
if (dto.getKey() == null || dto.getKey().isEmpty()) {
if (formData != null && formData.getFormFields() != null && !formData.getFormFields().isEmpty()) {
dto.setKey("embedded:engine://engine/:engine/process-definition/" + processDefinitionId + "/rendered-form");
}
}
dto.setContextPath(ApplicationContextPathUtil.getApplicationPathByProcessDefinitionId(engine, processDefinitionId));
return dto;
}
use of org.camunda.bpm.engine.form.StartFormData in project camunda-bpm-platform by camunda.
the class DelegationAuthorizationTest method testCustomStartFormHandlerExecutesQuery.
@Deployment
public void testCustomStartFormHandlerExecutesQuery() {
// given
startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
String processDefinitionId = selectProcessDefinitionByKey(DEFAULT_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, DEFAULT_PROCESS_KEY, userId, READ);
// when
StartFormData startFormData = formService.getStartFormData(processDefinitionId);
// then
assertNotNull(startFormData);
assertNotNull(MyDelegationService.CURRENT_AUTHENTICATION);
assertEquals(userId, MyDelegationService.CURRENT_AUTHENTICATION.getUserId());
assertEquals(Long.valueOf(5), MyDelegationService.INSTANCES_COUNT);
}
use of org.camunda.bpm.engine.form.StartFormData in project camunda-bpm-platform by camunda.
the class FormServiceTest method testTaskFormPropertyDefaultsAndFormRendering.
@Test
public void testTaskFormPropertyDefaultsAndFormRendering() {
final String deploymentId = testRule.deploy("org/camunda/bpm/engine/test/api/form/FormsProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/form/start.form", "org/camunda/bpm/engine/test/api/form/task.form").getId();
String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
StartFormData startForm = formService.getStartFormData(procDefId);
assertNotNull(startForm);
assertEquals(deploymentId, startForm.getDeploymentId());
assertEquals("org/camunda/bpm/engine/test/api/form/start.form", startForm.getFormKey());
assertEquals(new ArrayList<FormProperty>(), startForm.getFormProperties());
assertEquals(procDefId, startForm.getProcessDefinition().getId());
Object renderedStartForm = formService.getRenderedStartForm(procDefId, "juel");
assertEquals("start form content", renderedStartForm);
Map<String, String> properties = new HashMap<String, String>();
properties.put("room", "5b");
properties.put("speaker", "Mike");
String processInstanceId = formService.submitStartFormData(procDefId, properties).getId();
Map<String, Object> expectedVariables = new HashMap<String, Object>();
expectedVariables.put("room", "5b");
expectedVariables.put("speaker", "Mike");
Map<String, Object> variables = runtimeService.getVariables(processInstanceId);
assertEquals(expectedVariables, variables);
Task task = taskService.createTaskQuery().singleResult();
String taskId = task.getId();
TaskFormData taskForm = formService.getTaskFormData(taskId);
assertEquals(deploymentId, taskForm.getDeploymentId());
assertEquals("org/camunda/bpm/engine/test/api/form/task.form", taskForm.getFormKey());
assertEquals(new ArrayList<FormProperty>(), taskForm.getFormProperties());
assertEquals(taskId, taskForm.getTask().getId());
assertEquals("Mike is speaking in room 5b", formService.getRenderedTaskForm(taskId, "juel"));
properties = new HashMap<String, String>();
properties.put("room", "3f");
formService.submitTaskFormData(taskId, properties);
expectedVariables = new HashMap<String, Object>();
expectedVariables.put("room", "3f");
expectedVariables.put("speaker", "Mike");
variables = runtimeService.getVariables(processInstanceId);
assertEquals(expectedVariables, variables);
}
use of org.camunda.bpm.engine.form.StartFormData in project camunda-bpm-platform by camunda.
the class FormServiceTest method testBusinessKey.
@Deployment
@Test
public void testBusinessKey() {
// given
String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
// when
StartFormData startFormData = formService.getStartFormData(procDefId);
// then
FormField formField = startFormData.getFormFields().get(0);
assertTrue(formField.isBusinessKey());
}
Aggregations