Search in sources :

Example 11 with TaskFormData

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

the class FormDataTest method testGetFormFieldValidationConstraints.

@Deployment
public void testGetFormFieldValidationConstraints() {
    runtimeService.startProcessInstanceByKey("FormDataTest.testGetFormFieldValidationConstraints");
    Task task = taskService.createTaskQuery().singleResult();
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    List<FormField> formFields = taskFormData.getFormFields();
    FormField field1 = formFields.get(0);
    List<FormFieldValidationConstraint> validationConstraints = field1.getValidationConstraints();
    FormFieldValidationConstraint constraint1 = validationConstraints.get(0);
    assertEquals("maxlength", constraint1.getName());
    assertEquals("10", constraint1.getConfiguration());
    FormFieldValidationConstraint constraint2 = validationConstraints.get(1);
    assertEquals("minlength", constraint2.getName());
    assertEquals("5", constraint2.getConfiguration());
}
Also used : Task(org.camunda.bpm.engine.task.Task) FormFieldValidationConstraint(org.camunda.bpm.engine.form.FormFieldValidationConstraint) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) FormField(org.camunda.bpm.engine.form.FormField) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 12 with TaskFormData

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

the class FormDataTest method testGetFormFieldProperties.

@Deployment
public void testGetFormFieldProperties() {
    runtimeService.startProcessInstanceByKey("FormDataTest.testGetFormFieldProperties");
    Task task = taskService.createTaskQuery().singleResult();
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    List<FormField> formFields = taskFormData.getFormFields();
    FormField stringField = formFields.get(0);
    Map<String, String> properties = stringField.getProperties();
    assertEquals("property1", properties.get("p1"));
    assertEquals("property2", properties.get("p2"));
}
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 13 with TaskFormData

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

the class MultiTenancyFormServiceCmdsTenantCheckTest method testGetTaskFormWithAuthenticatedTenant.

// GetTaskForm test
@Test
public void testGetTaskFormWithAuthenticatedTenant() {
    testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml");
    runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
    identityService.setAuthentication("aUserId", null, Arrays.asList(TENANT_ONE));
    String taskId = taskService.createTaskQuery().singleResult().getId();
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    // then
    assertNotNull(taskFormData);
    assertEquals("aTaskFormKey", taskFormData.getFormKey());
}
Also used : TaskFormData(org.camunda.bpm.engine.form.TaskFormData) Test(org.junit.Test)

Example 14 with TaskFormData

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

the class MultiTenancyFormServiceCmdsTenantCheckTest method testGetTaskFormWithDisabledTenantCheck.

@Test
public void testGetTaskFormWithDisabledTenantCheck() {
    testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml");
    runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
    String taskId = taskService.createTaskQuery().singleResult().getId();
    identityService.setAuthentication("aUserId", null);
    processEngineConfiguration.setTenantCheckEnabled(false);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    // then
    assertNotNull(taskFormData);
    assertEquals("aTaskFormKey", taskFormData.getFormKey());
}
Also used : TaskFormData(org.camunda.bpm.engine.form.TaskFormData) Test(org.junit.Test)

Example 15 with TaskFormData

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

the class MockProvider method createMockTaskFormData.

public static TaskFormData createMockTaskFormData() {
    FormProperty mockFormProperty = mock(FormProperty.class);
    when(mockFormProperty.getId()).thenReturn(EXAMPLE_FORM_PROPERTY_ID);
    when(mockFormProperty.getName()).thenReturn(EXAMPLE_FORM_PROPERTY_NAME);
    when(mockFormProperty.getValue()).thenReturn(EXAMPLE_FORM_PROPERTY_VALUE);
    when(mockFormProperty.isReadable()).thenReturn(EXAMPLE_FORM_PROPERTY_READABLE);
    when(mockFormProperty.isWritable()).thenReturn(EXAMPLE_FORM_PROPERTY_WRITABLE);
    when(mockFormProperty.isRequired()).thenReturn(EXAMPLE_FORM_PROPERTY_REQUIRED);
    FormType mockFormType = mock(FormType.class);
    when(mockFormType.getName()).thenReturn(EXAMPLE_FORM_PROPERTY_TYPE_NAME);
    when(mockFormProperty.getType()).thenReturn(mockFormType);
    TaskFormData mockFormData = mock(TaskFormData.class);
    when(mockFormData.getFormKey()).thenReturn(EXAMPLE_FORM_KEY);
    when(mockFormData.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID);
    List<FormProperty> mockFormProperties = new ArrayList<FormProperty>();
    mockFormProperties.add(mockFormProperty);
    when(mockFormData.getFormProperties()).thenReturn(mockFormProperties);
    return mockFormData;
}
Also used : FormProperty(org.camunda.bpm.engine.form.FormProperty) FormType(org.camunda.bpm.engine.form.FormType) ArrayList(java.util.ArrayList) TaskFormData(org.camunda.bpm.engine.form.TaskFormData)

Aggregations

TaskFormData (org.camunda.bpm.engine.form.TaskFormData)26 Task (org.camunda.bpm.engine.task.Task)10 Deployment (org.camunda.bpm.engine.test.Deployment)10 Test (org.junit.Test)9 FormField (org.camunda.bpm.engine.form.FormField)8 FormProperty (org.camunda.bpm.engine.form.FormProperty)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)4 LinkedHashMap (java.util.LinkedHashMap)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 FormType (org.camunda.bpm.engine.form.FormType)2 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)2 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 ProcessApplicationService (org.camunda.bpm.ProcessApplicationService)1