Java Code Examples for org.flowable.engine.runtime.ProcessInstance#getProcessDefinitionId()

The following examples show how to use org.flowable.engine.runtime.ProcessInstance#getProcessDefinitionId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testTheCandidateGroupOfTheFirstTasksIsChanged() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode processInfo = dynamicBpmnService.changeUserTaskCandidateGroup(TASK_ONE_SID, "HR", false);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, processInfo);

    ArrayNode dynamicCandidateGroups = processEngineConfiguration.getObjectMapper().createArrayNode();
    dynamicCandidateGroups.add("HR");

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);

    JsonNode taskOneNode = summary.getElement(TASK_ONE_SID).get(ELEMENT_PROPERTIES);
    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_GROUPS).get(DYNAMIC_VALUE), is(dynamicCandidateGroups));
}
 
Example 2
Source File: DynamicUserTaskTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment
public void testChangeFormKey() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test", task.getFormKey());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());

    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskFormKey("task1", "test2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test2", task.getFormKey());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());
}
 
Example 3
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testTheCandidateGroupOfTheFirstTasksIsChangedMultipleTimes() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode processInfo = dynamicBpmnService.changeUserTaskCandidateGroup(TASK_ONE_SID, "HR", false);
    dynamicBpmnService.changeUserTaskCandidateGroup(TASK_ONE_SID, "SALES", false, processInfo);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, processInfo);

    ArrayNode candidateGroups = processEngineConfiguration.getObjectMapper().createArrayNode();
    candidateGroups.add("HR");
    candidateGroups.add("SALES");

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);
    JsonNode taskOneNode = summary.getElement(TASK_ONE_SID).get(ELEMENT_PROPERTIES);

    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_GROUPS).get(DYNAMIC_VALUE), is(candidateGroups));
}
 
Example 4
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testTheCandidateGroupOfTheFirstTasksIsChangedMultipleTimes() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode processInfo = dynamicBpmnService.changeUserTaskCandidateGroup(TASK_ONE_SID, "HR", false);
    dynamicBpmnService.changeUserTaskCandidateGroup(TASK_ONE_SID, "SALES", false, processInfo);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, processInfo);

    ArrayNode candidateGroups = processEngineConfiguration.getObjectMapper().createArrayNode();
    candidateGroups.add("HR");
    candidateGroups.add("SALES");

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);
    JsonNode taskOneNode = summary.getElement(TASK_ONE_SID).get(ELEMENT_PROPERTIES);

    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_GROUPS).get(DYNAMIC_VALUE), is(candidateGroups));
}
 
Example 5
Source File: DisabledDefinitionInfoCacheTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testChangeFormKey() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test", task.getFormKey());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());

    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskFormKey("task1", "test2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test", task.getFormKey());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());
}
 
Example 6
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testTheCandidateGroupOfTheFirstTasksIsChanged() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode processInfo = dynamicBpmnService.changeUserTaskCandidateGroup(TASK_ONE_SID, "HR", false);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, processInfo);

    ArrayNode dynamicCandidateGroups = processEngineConfiguration.getObjectMapper().createArrayNode();
    dynamicCandidateGroups.add("HR");

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);

    JsonNode taskOneNode = summary.getElement(TASK_ONE_SID).get(ELEMENT_PROPERTIES);
    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_GROUPS).get(DYNAMIC_VALUE), is(dynamicCandidateGroups));
}
 
Example 7
Source File: ScriptTaskTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testDynamicScript() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testDynamicScript", CollectionUtil.map("a", 20, "b", 22));
    assertEquals(42.0, runtimeService.getVariable(processInstance.getId(), "test"));
    taskService.complete(taskService.createTaskQuery().singleResult().getId());
    assertProcessEnded(processInstance.getId());

    String processDefinitionId = processInstance.getProcessDefinitionId();
    ObjectNode infoNode = dynamicBpmnService.changeScriptTaskScript("script1", "var sum = c + d;\nexecution.setVariable('test2', sum);");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    processInstance = runtimeService.startProcessInstanceByKey("testDynamicScript", CollectionUtil.map("c", 10, "d", 12));
    assertEquals(22.0, runtimeService.getVariable(processInstance.getId(), "test2"));
    taskService.complete(taskService.createTaskQuery().singleResult().getId());
    assertProcessEnded(processInstance.getId());
}
 
Example 8
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testItShouldBePossibleToResetDynamicCandidateUsers() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode jsonNodes = dynamicBpmnService.changeUserTaskCandidateUser(TASK_ONE_SID, "bob", false);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, jsonNodes);

    // delete
    jsonNodes = dynamicBpmnService.getProcessDefinitionInfo(processDefinitionId);
    dynamicBpmnService.resetProperty(TASK_ONE_SID, USER_TASK_CANDIDATE_USERS, jsonNodes);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, jsonNodes);

    runtimeService.startProcessInstanceByKey("dynamicServiceTest");

    long count = taskService.createTaskQuery().taskCandidateUser("david").count();
    assertThat(count, is(2L));

    // additional checks of summary
    ArrayNode candidateUsersNode = processEngineConfiguration.getObjectMapper().createArrayNode();
    candidateUsersNode.add("david");

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);
    JsonNode candidateUsers = summary.getElement(TASK_ONE_SID).get(ELEMENT_PROPERTIES).get(USER_TASK_CANDIDATE_USERS);
    assertThat((ArrayNode) candidateUsers.get(BPMN_MODEL_VALUE), is(candidateUsersNode));
    assertThat(candidateUsers.get(DYNAMIC_VALUE), is(nullValue()));
}
 
Example 9
Source File: DynamicUserTaskTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment
public void testChangeFormKeyWithExpression() {
    // first test without changing the form key
    Map<String, Object> varMap = new HashMap<>();
    varMap.put("start", "test");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask", varMap);
    String processDefinitionId = processInstance.getProcessDefinitionId();

    org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test", task.getFormKey());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());

    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskFormKey("task1", "${anotherKey}");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    varMap = new HashMap<>();
    varMap.put("anotherKey", "test2");
    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask", varMap);

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("test2", task.getFormKey());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());
}
 
Example 10
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testTheScriptOfTheScriptTasksIsChanged() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode jsonNodes = dynamicBpmnService.changeScriptTaskScript(SCRIPT_TASK_SID, "var x = \"hallo\";");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, jsonNodes);

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);
    JsonNode scriptTaskNode = summary.getElement(SCRIPT_TASK_SID).get(ELEMENT_PROPERTIES);

    assertThat(scriptTaskNode.get(SCRIPT_TASK_SCRIPT).get(DYNAMIC_VALUE).asText(), is("var x = \"hallo\";"));
}
 
Example 11
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testTheCandidateUserOfTheFirstTasksIsChangedMultipleTimes() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode processInfo = dynamicBpmnService.changeUserTaskCandidateUser(TASK_ONE_SID, "bob", false);
    dynamicBpmnService.changeUserTaskCandidateUser(TASK_ONE_SID, "david", false, processInfo);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, processInfo);

    ArrayNode bpmnModelCandidateUsers = processEngineConfiguration.getObjectMapper().createArrayNode();
    bpmnModelCandidateUsers.add("david");

    ArrayNode dynamicCandidateUsers = processEngineConfiguration.getObjectMapper().createArrayNode();
    dynamicCandidateUsers.add("bob");
    dynamicCandidateUsers.add("david");

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);

    JsonNode taskOneNode = summary.getElement(TASK_ONE_SID).get(ELEMENT_PROPERTIES);
    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_USERS).get(BPMN_MODEL_VALUE), is(bpmnModelCandidateUsers));
    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_USERS).get(DYNAMIC_VALUE), is(dynamicCandidateUsers));

    // verify if runtime is up to date
    runtimeService.startProcessInstanceById(processDefinitionId);

    org.flowable.task.api.Task bobTask = taskService.createTaskQuery().taskCandidateUser("bob").singleResult();
    assertThat("Bob must have one task", bobTask, is(notNullValue()));

    List<org.flowable.task.api.Task> davidTasks = taskService.createTaskQuery().taskCandidateUser("david").list();
    assertThat("David must have two task", davidTasks.size(), is(2));
}
 
Example 12
Source File: DynamicServiceTaskTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testChangeClassName() {
    // first test without changing the class name
    Map<String, Object> varMap = new HashMap<String, Object>();
    varMap.put("count", 0);
    varMap.put("count2", 0);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);

    org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());

    assertEquals(1, runtimeService.getVariable(processInstance.getId(), "count"));
    assertEquals(0, runtimeService.getVariable(processInstance.getId(), "count2"));

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());

    // now test with changing the class name
    varMap = new HashMap<String, Object>();
    varMap.put("count", 0);
    varMap.put("count2", 0);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);

    String processDefinitionId = processInstance.getProcessDefinitionId();
    ObjectNode infoNode = dynamicBpmnService.changeServiceTaskClassName("service", "org.activiti.engine.test.bpmn.servicetask.DummyServiceTask2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());

    assertEquals(0, runtimeService.getVariable(processInstance.getId(), "count"));
    assertEquals(1, runtimeService.getVariable(processInstance.getId(), "count2"));

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());
}
 
Example 13
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testTheCandidateUserOfTheFirstTasksIsChangedMultipleTimes() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode processInfo = dynamicBpmnService.changeUserTaskCandidateUser(TASK_ONE_SID, "bob", false);
    dynamicBpmnService.changeUserTaskCandidateUser(TASK_ONE_SID, "david", false, processInfo);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, processInfo);

    ArrayNode bpmnModelCandidateUsers = processEngineConfiguration.getObjectMapper().createArrayNode();
    bpmnModelCandidateUsers.add("david");

    ArrayNode dynamicCandidateUsers = processEngineConfiguration.getObjectMapper().createArrayNode();
    dynamicCandidateUsers.add("bob");
    dynamicCandidateUsers.add("david");

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);

    JsonNode taskOneNode = summary.getElement(TASK_ONE_SID).get(ELEMENT_PROPERTIES);
    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_USERS).get(BPMN_MODEL_VALUE), is(bpmnModelCandidateUsers));
    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_USERS).get(DYNAMIC_VALUE), is(dynamicCandidateUsers));

    // verify if runtime is up to date
    runtimeService.startProcessInstanceById(processDefinitionId);

    org.flowable.task.api.Task bobTask = taskService.createTaskQuery().taskCandidateUser("bob").singleResult();
    assertThat("Bob must have one task", bobTask, is(notNullValue()));

    List<org.flowable.task.api.Task> davidTasks = taskService.createTaskQuery().taskCandidateUser("david").list();
    assertThat("David must have two task", davidTasks.size(), is(2));
}
 
Example 14
Source File: DynamicUserTaskTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/bpmn/usertask/DynamicUserTaskTest.basictask.bpmn20.xml" })
public void testChangeNameAndDescription() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNull(task.getName());
    assertNull(task.getDescription());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());

    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskName("task1", "Task name test");
    dynamicBpmnService.changeUserTaskDescription("task1", "Task description test", infoNode);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("Task name test", task.getName());
    assertEquals("Task description test", task.getDescription());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());
}
 
Example 15
Source File: DynamicProcessDefinitionSummaryTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/bpmn/dynamic/dynamic-bpmn-test-process.bpmn20.xml" })
public void testTheCandidateUserOfTheFirstTasksIsChanged() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTest");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    ObjectNode processInfo = dynamicBpmnService.changeUserTaskCandidateUser(TASK_ONE_SID, "bob", false);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, processInfo);

    DynamicProcessDefinitionSummary summary = dynamicBpmnService.getDynamicProcessDefinitionSummary(processDefinitionId);

    ArrayNode bpmnModelCandidateUsers = processEngineConfiguration.getObjectMapper().createArrayNode();
    bpmnModelCandidateUsers.add("david");

    ArrayNode dynamicCandidateUsers = processEngineConfiguration.getObjectMapper().createArrayNode();
    dynamicCandidateUsers.add("bob");

    JsonNode taskOneNode = summary.getElement(TASK_ONE_SID).get(ELEMENT_PROPERTIES);
    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_USERS).get(BPMN_MODEL_VALUE), is(bpmnModelCandidateUsers));
    assertThat((ArrayNode) taskOneNode.get(USER_TASK_CANDIDATE_USERS).get(DYNAMIC_VALUE), is(dynamicCandidateUsers));

    // verify if runtime is up to date
    runtimeService.startProcessInstanceById(processDefinitionId);
    // bob and david both should have a single task.
    org.flowable.task.api.Task bobTask = taskService.createTaskQuery().taskCandidateUser("bob").singleResult();
    assertThat("Bob must have one task", bobTask, is(notNullValue()));

    org.flowable.task.api.Task davidTask = taskService.createTaskQuery().taskCandidateUser("david").singleResult();
    assertThat("David must have one task", davidTask, is(not(nullValue())));
}
 
Example 16
Source File: DynamicUserTaskTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/bpmn/usertask/DynamicUserTaskTest.assignment.bpmn20.xml" })
public void testChangePriorityAndCategory() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals(50, task.getPriority());
    assertNull(task.getCategory());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());

    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskPriority("task1", "99");
    dynamicBpmnService.changeUserTaskCategory("task1", "categoryTest", infoNode);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals(99, task.getPriority());
    assertEquals("categoryTest", task.getCategory());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());
}
 
Example 17
Source File: DynamicUserTaskTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/bpmn/usertask/DynamicUserTaskTest.basictask.bpmn20.xml" })
public void testChangeNameAndDescription() {
    // first test without changing the form key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
    String processDefinitionId = processInstance.getProcessDefinitionId();

    org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNull(task.getName());
    assertNull(task.getDescription());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());

    // now test with changing the form key
    ObjectNode infoNode = dynamicBpmnService.changeUserTaskName("task1", "Task name test");
    dynamicBpmnService.changeUserTaskDescription("task1", "Task description test", infoNode);
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("Task name test", task.getName());
    assertEquals("Task description test", task.getDescription());
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());
}
 
Example 18
Source File: ProcessInstanceCollectionResourceTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
/**
 * Test getting a list of process instance, using all possible filters.
 */
@Test
@Deployment(resources = { "org/flowable/rest/service/api/runtime/ProcessInstanceResourceTest.process-one.bpmn20.xml" })
public void testGetProcessInstances() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne", "myBusinessKey");
    String id = processInstance.getId();
    runtimeService.addUserIdentityLink(id, "kermit", "whatever");

    // Test without any parameters
    String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION);
    assertResultsPresentInDataResponse(url, id);

    // Process instance id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?id=" + id;
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?id=anotherId";
    assertResultsPresentInDataResponse(url);

    // Process instance business key
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?businessKey=myBusinessKey";
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?businessKey=anotherBusinessKey";
    assertResultsPresentInDataResponse(url);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?businessKeyLike=" + encode("%BusinessKey");
    assertResultsPresentInDataResponse(url, id);

    // Process definition key
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?processDefinitionKey=processOne";
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?processDefinitionKey=processTwo";
    assertResultsPresentInDataResponse(url);

    // Process definition id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?processDefinitionId=" + processInstance.getProcessDefinitionId();
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?processDefinitionId=anotherId";
    assertResultsPresentInDataResponse(url);

    // Involved user
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?involvedUser=kermit";
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?involvedUser=gonzo";
    assertResultsPresentInDataResponse(url);

    // Active process
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?suspended=false";
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?suspended=true";
    assertResultsPresentInDataResponse(url);

    // Suspended process
    runtimeService.suspendProcessInstanceById(id);
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?suspended=true";
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?suspended=false";
    assertResultsPresentInDataResponse(url);
    runtimeService.activateProcessInstanceById(id);

    // Complete first task in the process to have a subprocess created
    taskService.complete(taskService.createTaskQuery().processInstanceId(id).singleResult().getId());

    ProcessInstance subProcess = runtimeService.createProcessInstanceQuery().superProcessInstanceId(id).singleResult();
    assertThat(subProcess).isNotNull();

    // Super-process instance id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?superProcessInstanceId=" + id;
    assertResultsPresentInDataResponse(url, subProcess.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?superProcessInstanceId=anotherId";
    assertResultsPresentInDataResponse(url);

    // Sub-process instance id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?subProcessInstanceId=" + subProcess.getId();
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?subProcessInstanceId=anotherId";
    assertResultsPresentInDataResponse(url);
}
 
Example 19
Source File: ExecutionCollectionResourceTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
/**
 * Test getting a list of executions, using all possible filters.
 */
@Test
@Deployment(resources = { "org/flowable/rest/service/api/runtime/ExecutionResourceTest.process-with-subprocess.bpmn20.xml" })
public void testGetExecutions() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne", "myBusinessKey");
    String id = processInstance.getId();
    runtimeService.addUserIdentityLink(id, "kermit", "whatever");

    Execution childExecutionInTask = runtimeService.createExecutionQuery().activityId("processTask").singleResult();
    assertThat(childExecutionInTask).isNotNull();

    Execution childExecutionInSubProcess = runtimeService.createExecutionQuery().activityId("subProcess").singleResult();
    assertThat(childExecutionInSubProcess).isNotNull();

    // Test without any parameters
    String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION);
    assertResultsPresentInDataResponse(url, id, childExecutionInTask.getId(), childExecutionInSubProcess.getId());

    // Process instance id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?id=" + id;
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?id=anotherId";
    assertResultsPresentInDataResponse(url);

    // Process instance business key
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?processInstanceBusinessKey=myBusinessKey";
    assertResultsPresentInDataResponse(url, id);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?processInstanceBusinessKey=anotherBusinessKey";
    assertResultsPresentInDataResponse(url);

    // Process definition key
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?processDefinitionKey=processOne";
    assertResultsPresentInDataResponse(url, id, childExecutionInTask.getId(), childExecutionInSubProcess.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?processDefinitionKey=processTwo";
    assertResultsPresentInDataResponse(url);

    // Process definition id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?processDefinitionId=" + processInstance.getProcessDefinitionId();
    assertResultsPresentInDataResponse(url, id, childExecutionInTask.getId(), childExecutionInSubProcess.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?processDefinitionId=anotherId";
    assertResultsPresentInDataResponse(url);

    // Parent id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?parentId=" + id;
    assertResultsPresentInDataResponse(url, childExecutionInSubProcess.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?parentId=anotherId";
    assertResultsPresentInDataResponse(url);

    // Activity id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?activityId=processTask";
    assertResultsPresentInDataResponse(url, childExecutionInTask.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?activityId=anotherId";
    assertResultsPresentInDataResponse(url);

    // Without tenant ID, before tenant is set
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?withoutTenantId=true";
    assertResultsPresentInDataResponse(url, id, childExecutionInTask.getId(), childExecutionInSubProcess.getId());

    // Update the tenant for the deployment
    managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant"));

    // Without tenant ID, after tenant is set
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?withoutTenantId=true";
    assertResultsPresentInDataResponse(url);

    // Tenant id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?tenantId=myTenant";
    assertResultsPresentInDataResponse(url, id, childExecutionInTask.getId(), childExecutionInSubProcess.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?tenantId=myTenant2";
    assertResultsPresentInDataResponse(url);

    // Tenant id like
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?tenantIdLike=" + encode("%enant");
    assertResultsPresentInDataResponse(url, id, childExecutionInTask.getId(), childExecutionInSubProcess.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION) + "?tenantIdLike=" + encode("%whatever");
    assertResultsPresentInDataResponse(url);
}
 
Example 20
Source File: DisabledDefinitionInfoCacheTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
@Deployment
public void testChangeClassName() {
    // first test without changing the class name
    Map<String, Object> varMap = new HashMap<>();
    varMap.put("count", 0);
    varMap.put("count2", 0);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);

    org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());

    assertEquals(1, runtimeService.getVariable(processInstance.getId(), "count"));
    assertEquals(0, runtimeService.getVariable(processInstance.getId(), "count2"));

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());

    // now test with changing the class name
    varMap = new HashMap<>();
    varMap.put("count", 0);
    varMap.put("count2", 0);
    processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);

    String processDefinitionId = processInstance.getProcessDefinitionId();
    ObjectNode infoNode = dynamicBpmnService.changeServiceTaskClassName("service", "org.flowable.engine.test.bpmn.servicetask.DummyServiceTask2");
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());

    assertEquals(1, runtimeService.getVariable(processInstance.getId(), "count"));
    assertEquals(0, runtimeService.getVariable(processInstance.getId(), "count2"));

    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());

    assertProcessEnded(processInstance.getId());
}