Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2b8819
commit b47126b
Showing
9 changed files
with
198 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
...-engine-configurator/src/test/java/org/flowable/engine/configurator/test/ProcessTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.flowable.engine.configurator.test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.flowable.app.api.repository.AppDeployment; | ||
import org.flowable.app.engine.test.FlowableAppTestCase; | ||
import org.flowable.common.engine.api.FlowableObjectNotFoundException; | ||
import org.flowable.common.engine.impl.interceptor.EngineConfigurationConstants; | ||
import org.flowable.engine.ProcessEngineConfiguration; | ||
import org.flowable.engine.RuntimeService; | ||
import org.flowable.engine.TaskService; | ||
import org.flowable.engine.runtime.ProcessInstance; | ||
import org.flowable.form.api.FormDefinition; | ||
import org.flowable.form.engine.FormEngineConfiguration; | ||
import org.flowable.identitylink.api.IdentityLinkType; | ||
import org.flowable.task.api.Task; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author Tijs Rademakers | ||
*/ | ||
public class ProcessTest extends FlowableAppTestCase { | ||
|
||
@Test | ||
public void testCompleteTask() throws Exception { | ||
ProcessEngineConfiguration processEngineConfiguration = (ProcessEngineConfiguration) appEngineConfiguration.getEngineConfigurations() | ||
.get(EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG); | ||
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService(); | ||
TaskService taskService = processEngineConfiguration.getTaskService(); | ||
|
||
AppDeployment deployment = appRepositoryService.createDeployment() | ||
.addClasspathResource("org/flowable/engine/configurator/test/oneTaskProcess.bpmn20.xml").deploy(); | ||
|
||
try { | ||
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTask"); | ||
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); | ||
assertNotNull(task); | ||
|
||
runtimeService.addUserIdentityLink(processInstance.getId(), "anotherUser", IdentityLinkType.STARTER); | ||
taskService.addUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT); | ||
|
||
assertEquals(2, runtimeService.getIdentityLinksForProcessInstance(processInstance.getId()).size()); | ||
assertEquals(1, taskService.getIdentityLinksForTask(task.getId()).size()); | ||
|
||
taskService.complete(task.getId()); | ||
|
||
try { | ||
assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstance.getId()).size()); | ||
fail("object not found expected"); | ||
} catch (FlowableObjectNotFoundException e) { | ||
// expected | ||
} | ||
|
||
try { | ||
assertEquals(0, taskService.getIdentityLinksForTask(task.getId()).size()); | ||
fail("object not found expected"); | ||
} catch (FlowableObjectNotFoundException e) { | ||
// expected | ||
} | ||
|
||
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count()); | ||
|
||
|
||
} finally { | ||
appRepositoryService.deleteDeployment(deployment.getId(), true); | ||
} | ||
} | ||
|
||
@Test | ||
public void testCompleteTaskWithForm() throws Exception { | ||
ProcessEngineConfiguration processEngineConfiguration = (ProcessEngineConfiguration) appEngineConfiguration.getEngineConfigurations() | ||
.get(EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG); | ||
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService(); | ||
TaskService taskService = processEngineConfiguration.getTaskService(); | ||
|
||
AppDeployment deployment = appRepositoryService.createDeployment() | ||
.addClasspathResource("org/flowable/engine/configurator/test/oneTaskWithFormProcess.bpmn20.xml") | ||
.addClasspathResource("org/flowable/engine/configurator/test/simple.form").deploy(); | ||
|
||
try { | ||
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTask"); | ||
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); | ||
assertNotNull(task); | ||
|
||
runtimeService.addUserIdentityLink(processInstance.getId(), "anotherUser", IdentityLinkType.STARTER); | ||
taskService.addUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT); | ||
|
||
assertEquals(2, runtimeService.getIdentityLinksForProcessInstance(processInstance.getId()).size()); | ||
assertEquals(1, taskService.getIdentityLinksForTask(task.getId()).size()); | ||
|
||
FormEngineConfiguration formEngineConfiguration = (FormEngineConfiguration) appEngineConfiguration.getEngineConfigurations() | ||
.get(EngineConfigurationConstants.KEY_FORM_ENGINE_CONFIG); | ||
FormDefinition formDefinition = formEngineConfiguration.getFormRepositoryService().createFormDefinitionQuery().formDefinitionKey("form1").singleResult(); | ||
assertNotNull(formDefinition); | ||
|
||
Map<String, Object> variables = new HashMap<String, Object>(); | ||
variables.put("input1", "test"); | ||
taskService.completeTaskWithForm(task.getId(), formDefinition.getId(), null, variables); | ||
|
||
try { | ||
assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstance.getId()).size()); | ||
fail("object not found expected"); | ||
} catch (FlowableObjectNotFoundException e) { | ||
// expected | ||
} | ||
|
||
try { | ||
assertEquals(0, taskService.getIdentityLinksForTask(task.getId()).size()); | ||
fail("object not found expected"); | ||
} catch (FlowableObjectNotFoundException e) { | ||
// expected | ||
} | ||
|
||
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count()); | ||
|
||
|
||
} finally { | ||
appRepositoryService.deleteDeployment(deployment.getId(), true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...rc/test/resources/org/flowable/engine/configurator/test/oneTaskWithFormProcess.bpmn20.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" | ||
xmlns:flowable="http://flowable.org/bpmn" | ||
targetNamespace="http://flowable.org/bpmn"> | ||
<process id="oneTask"> | ||
<startEvent id="theStart" /> | ||
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" /> | ||
<userTask id="theTask" name="my task" flowable:formKey="form1" /> | ||
<sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" /> | ||
<endEvent id="theEnd" /> | ||
</process> | ||
</definitions> |
13 changes: 13 additions & 0 deletions
13
...-engine-configurator/src/test/resources/org/flowable/engine/configurator/test/simple.form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"key": "form1", | ||
"name": "My first form", | ||
"fields": [ | ||
{ | ||
"id": "input1", | ||
"name": "Input1", | ||
"type": "text", | ||
"required": false, | ||
"placeholder": "empty" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters