Search in sources :

Example 6 with StartFormData

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

the class MultiTenancyFormServiceCmdsTenantCheckTest method testGetStartFormWithAuthenticatedTenant.

// GetStartForm test
@Test
public void testGetStartFormWithAuthenticatedTenant() {
    testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml");
    ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
    identityService.setAuthentication("aUserId", null, Arrays.asList(TENANT_ONE));
    StartFormData startFormData = formService.getStartFormData(instance.getProcessDefinitionId());
    // then
    assertNotNull(startFormData);
    assertEquals("aStartFormKey", startFormData.getFormKey());
}
Also used : StartFormData(org.camunda.bpm.engine.form.StartFormData) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 7 with StartFormData

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

the class MultiTenancyFormServiceCmdsTenantCheckTest method testGetStartFormWithDisabledTenantCheck.

@Test
public void testGetStartFormWithDisabledTenantCheck() {
    testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml");
    ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
    identityService.setAuthentication("aUserId", null);
    processEngineConfiguration.setTenantCheckEnabled(false);
    StartFormData startFormData = formService.getStartFormData(instance.getProcessDefinitionId());
    // then
    assertNotNull(startFormData);
    assertEquals("aStartFormKey", startFormData.getFormKey());
}
Also used : StartFormData(org.camunda.bpm.engine.form.StartFormData) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 8 with StartFormData

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

the class ElResolveStartFormDataTest method testStartFormDataWithLabelExpression.

@Test
public void testStartFormDataWithLabelExpression() {
    String processDefinitionId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    StartFormData formData = formService.getStartFormData(processDefinitionId);
    String label = formData.getFormFields().get(0).getLabel();
    Assert.assertNotNull(label);
    Assert.assertEquals("testString123", label);
}
Also used : StartFormData(org.camunda.bpm.engine.form.StartFormData) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest) Test(org.junit.Test)

Example 9 with StartFormData

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

the class ProcessDefinitionRestServiceInteractionTest method testGetStartForm_shouldReturnKeyContainingTaskId_ByKey.

@Test
public void testGetStartForm_shouldReturnKeyContainingTaskId_ByKey() {
    ProcessDefinition mockDefinition = MockProvider.createMockDefinition();
    StartFormData mockStartFormData = MockProvider.createMockStartFormDataUsingFormFieldsWithoutFormKey(mockDefinition);
    when(formServiceMock.getStartFormData(mockDefinition.getId())).thenReturn(mockStartFormData);
    given().pathParam("key", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY).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_BY_KEY_URL);
}
Also used : StartFormData(org.camunda.bpm.engine.form.StartFormData) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 10 with StartFormData

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

the class ProcessDefinitionRestServiceInteractionTest method setUpRuntimeDataForDefinition.

private void setUpRuntimeDataForDefinition(ProcessDefinition mockDefinition) {
    mockInstance = MockProvider.createMockInstanceWithVariables();
    // we replace this mock with every test in order to have a clean one (in terms of invocations) for verification
    runtimeServiceMock = mock(RuntimeService.class);
    when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock);
    when(runtimeServiceMock.startProcessInstanceById(eq(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID), Matchers.<Map<String, Object>>any())).thenReturn(mockInstance);
    when(runtimeServiceMock.startProcessInstanceById(eq(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID), anyString(), anyString(), Matchers.<Map<String, Object>>any())).thenReturn(mockInstance);
    mockInstantiationBuilder = setUpMockInstantiationBuilder();
    when(mockInstantiationBuilder.executeWithVariablesInReturn(anyBoolean(), anyBoolean())).thenReturn(mockInstance);
    when(runtimeServiceMock.createProcessInstanceById(anyString())).thenReturn(mockInstantiationBuilder);
    repositoryServiceMock = mock(RepositoryService.class);
    when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
    when(repositoryServiceMock.getProcessDefinition(eq(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID))).thenReturn(mockDefinition);
    when(repositoryServiceMock.getProcessModel(eq(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID))).thenReturn(createMockProcessDefinionBpmn20Xml());
    DeleteProcessDefinitionsSelectBuilder deleteProcessDefinitionsSelectBuilder = mock(DeleteProcessDefinitionsSelectBuilder.class, RETURNS_DEEP_STUBS);
    when(repositoryServiceMock.deleteProcessDefinitions()).thenReturn(deleteProcessDefinitionsSelectBuilder);
    setUpMockDefinitionQuery(mockDefinition);
    StartFormData formDataMock = MockProvider.createMockStartFormData(mockDefinition);
    formServiceMock = mock(FormService.class);
    when(processEngine.getFormService()).thenReturn(formServiceMock);
    when(formServiceMock.getStartFormData(eq(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID))).thenReturn(formDataMock);
    when(formServiceMock.submitStartForm(eq(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID), Matchers.<Map<String, Object>>any())).thenReturn(mockInstance);
    when(formServiceMock.submitStartForm(eq(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID), anyString(), Matchers.<Map<String, Object>>any())).thenReturn(mockInstance);
    VariableMap startFormVariablesMock = MockProvider.createMockFormVariables();
    when(formServiceMock.getStartFormVariables(eq(EXAMPLE_PROCESS_DEFINITION_ID), Matchers.<Collection<String>>any(), anyBoolean())).thenReturn(startFormVariablesMock);
}
Also used : DeleteProcessDefinitionsSelectBuilder(org.camunda.bpm.engine.repository.DeleteProcessDefinitionsSelectBuilder) VariableMap(org.camunda.bpm.engine.variable.VariableMap) StartFormData(org.camunda.bpm.engine.form.StartFormData) Matchers.anyString(org.mockito.Matchers.anyString)

Aggregations

StartFormData (org.camunda.bpm.engine.form.StartFormData)19 Test (org.junit.Test)10 Deployment (org.camunda.bpm.engine.test.Deployment)5 FormField (org.camunda.bpm.engine.form.FormField)4 FormProperty (org.camunda.bpm.engine.form.FormProperty)4 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 VariableMap (org.camunda.bpm.engine.variable.VariableMap)3 LinkedHashMap (java.util.LinkedHashMap)2 FormType (org.camunda.bpm.engine.form.FormType)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1 FormService (org.camunda.bpm.engine.FormService)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 ScriptEvaluationException (org.camunda.bpm.engine.ScriptEvaluationException)1 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)1