org.flowable.engine.ManagementService Java Examples
The following examples show how to use
org.flowable.engine.ManagementService.
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: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void deleteTaskWithLogEntries(TaskService taskService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration, String taskId) { taskService.deleteTask(taskId, true); managementService.executeCommand(new Command<Void>() { @Override public Void execute(CommandContext commandContext) { HistoricTaskLogEntryEntityManager historicTaskLogEntryEntityManager = CommandContextUtil.getTaskServiceConfiguration(commandContext) .getHistoricTaskLogEntryEntityManager(); List<HistoricTaskLogEntry> taskLogEntries = historicTaskLogEntryEntityManager .findHistoricTaskLogEntriesByQueryCriteria(new HistoricTaskLogEntryQueryImpl(processEngineConfiguration.getCommandExecutor())); for (HistoricTaskLogEntry historicTaskLogEntry : taskLogEntries) { historicTaskLogEntryEntityManager.deleteHistoricTaskLogEntry(historicTaskLogEntry.getLogNumber()); } HistoryJobService historyJobService = CommandContextUtil.getHistoryJobService(commandContext); List<HistoryJob> jobs = historyJobService.findHistoryJobsByQueryCriteria(new HistoryJobQueryImpl(commandContext)); for (HistoryJob historyJob : jobs) { historyJobService.deleteHistoryJob((HistoryJobEntity) historyJob); } return null; } }); }
Example #2
Source File: CreateUserAndMembershipTestDelegate.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void execute(DelegateExecution execution) { ManagementService managementService = Context.getProcessEngineConfiguration().getManagementService(); managementService.executeCommand(new Command<Void>() { @Override public Void execute(CommandContext commandContext) { return null; } }); IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService(); String username = "Kermit"; User user = identityService.newUser(username); user.setPassword("123"); user.setFirstName("Manually"); user.setLastName("created"); identityService.saveUser(user); // Add admin group Group group = identityService.newGroup("admin"); identityService.saveGroup(group); identityService.createMembership(username, "admin"); }
Example #3
Source File: FlowableRuleJunit4Test.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/bpmn/async/AsyncTaskTest.testAsyncTask.bpmn20.xml" }) public void testWaitForJobs() { RuntimeService runtimeService = activitiRule.getRuntimeService(); ManagementService managementService = activitiRule.getManagementService(); // start process runtimeService.startProcessInstanceByKey("asyncTask"); // now there should be one job in the database: assertThat(managementService.createJobQuery().count()).isEqualTo(1); JobTestHelper.waitForJobExecutorToProcessAllJobs(activitiRule, 7000L, 500L); // the job is done assertThat(managementService.createJobQuery().count()).isZero(); }
Example #4
Source File: ActivitiRuleJunit4Test.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/activiti/engine/test/bpmn/async/AsyncTaskTest.testAsyncTask.bpmn20.xml" }) public void testWaitForJobs() { RuntimeService runtimeService = activitiRule.getRuntimeService(); ManagementService managementService = activitiRule.getManagementService(); // start process runtimeService.startProcessInstanceByKey("asyncTask"); // now there should be one job in the database: assertEquals(1, managementService.createJobQuery().count()); JobTestHelper.waitForJobExecutorToProcessAllJobs(activitiRule, 7000L, 500L); // the job is done assertEquals(0, managementService.createJobQuery().count()); }
Example #5
Source File: Application.java From flowable-engine with Apache License 2.0 | 6 votes |
@Bean CommandLineRunner customMybatisXmlMapper(final ManagementService managementService) { return new CommandLineRunner() { @Override public void run(String... args) throws Exception { String processDefinitionDeploymentId = managementService.executeCommand(new Command<String>() { @Override public String execute(CommandContext commandContext) { return (String) CommandContextUtil.getDbSqlSession() .selectOne("selectProcessDefinitionDeploymentIdByKey", "waiter"); } }); LOGGER.info("Process definition deployment id = {}", processDefinitionDeploymentId); } }; }
Example #6
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void queryForTaskLogEntriesByTasKId(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { task = taskService.createTaskBuilder(). assignee("testAssignee"). create(); Task anotherTask = taskService.createTaskBuilder().create(); try { if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(1); assertThat(logEntries.get(0)).extracting(HistoricTaskLogEntry::getTaskId).isEqualTo(task.getId()); assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isEqualTo(1l); } } finally { deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, anotherTask.getId()); } }
Example #7
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void changeDueDate(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { task = taskService.createTaskBuilder().create(); taskService.setDueDate(task.getId(), new Date()); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> taskLogEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(taskLogEntries).hasSize(2); taskLogEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_DUEDATE_CHANGED").list(); assertThat(taskLogEntries).hasSize(1); assertThat(taskLogEntries.get(0).getData()).contains("\"newDueDate\"", "\"previousDueDate\":null}"); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getTimeStamp).isNotNull(); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getTaskId).isEqualTo(task.getId()); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getUserId).isNull(); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getType).isEqualTo("USER_TASK_DUEDATE_CHANGED"); } }
Example #8
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void claimTaskEvent(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { task = taskService.createTaskBuilder().create(); taskService.claim(task.getId(), "testUser"); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> taskLogEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(taskLogEntries).hasSize(2); taskLogEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_ASSIGNEE_CHANGED").list(); assertThat(taskLogEntries).hasSize(1); assertThat(taskLogEntries.get(0).getData()).contains("\"newAssigneeId\":\"testUser\"", "\"previousAssigneeId\":null"); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getTimeStamp).isNotNull(); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getTaskId).isEqualTo(task.getId()); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getUserId).isNull(); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getType).isEqualTo("USER_TASK_ASSIGNEE_CHANGED"); } }
Example #9
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void taskOwnerEvent(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { task = taskService.createTaskBuilder(). assignee("initialAssignee"). create(); taskService.setOwner(task.getId(), "newOwner"); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> taskLogEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(taskLogEntries).hasSize(2); taskLogEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_OWNER_CHANGED").list(); assertThat(taskLogEntries).hasSize(1); assertThat(taskLogEntries.get(0).getData()). contains("\"previousOwnerId\":null", "\"newOwnerId\":\"newOwner\""); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getTimeStamp).isNotNull(); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getTaskId).isEqualTo(task.getId()); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getUserId).isNull(); assertThat(taskLogEntries.get(0)).extracting(HistoricTaskLogEntry::getType).isEqualTo("USER_TASK_OWNER_CHANGED"); } }
Example #10
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void deleteTaskEventLogEntry(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { task = taskService.createTaskBuilder(). assignee("testAssignee"). create(); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> taskLogsByTaskInstanceId = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(taskLogsByTaskInstanceId).hasSize(1); historyService.deleteHistoricTaskLogEntry(taskLogsByTaskInstanceId.get(0).getLogNumber()); HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 5000, 200); taskLogsByTaskInstanceId = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(taskLogsByTaskInstanceId).isEmpty(); } }
Example #11
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void queryForNullTaskLogEntries_returnsAll(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { Task taskA = taskService.createTaskBuilder().create(); Task taskB = taskService.createTaskBuilder().create(); Task taskC = taskService.createTaskBuilder().create(); try { if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> taskLogsByTaskInstanceId = historyService.createHistoricTaskLogEntryQuery().taskId(null).list(); assertThat(taskLogsByTaskInstanceId).hasSize(3); } } finally { deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, taskC.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, taskB.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, taskA.getId()); } }
Example #12
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogEntriesByScopeType(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { assertThatTaskLogIsFetched(taskService, historyService.createHistoricTaskLogEntryBuilder().scopeType("testScopeType"), historyService.createHistoricTaskLogEntryQuery().scopeType("testScopeType"), managementService, processEngineConfiguration); }
Example #13
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogEntriesByTenantId(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { assertThatTaskLogIsFetched(taskService, historyService.createHistoricTaskLogEntryBuilder().timeStamp(getInsertDate()), historyService.createHistoricTaskLogEntryQuery().from(getCompareBeforeDate()).to(getCompareAfterDate()), managementService, processEngineConfiguration); }
Example #14
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogEntriesByFromTimeStamp(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { assertThatAllTaskLogIsFetched(taskService, historyService.createHistoricTaskLogEntryBuilder().timeStamp(getInsertDate()), historyService.createHistoricTaskLogEntryQuery().from(getCompareBeforeDate()), managementService, processEngineConfiguration); }
Example #15
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogEntriesByFromToTimeStamp(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { assertThatTaskLogIsFetched(taskService, historyService.createHistoricTaskLogEntryBuilder().timeStamp(getInsertDate()), historyService.createHistoricTaskLogEntryQuery().from(getCompareBeforeDate()).to(getCompareAfterDate()), managementService, processEngineConfiguration); }
Example #16
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogEntriesByProcessInstanceId(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { assertThatTaskLogIsFetched(taskService, historyService.createHistoricTaskLogEntryBuilder().processInstanceId("testProcess"), historyService.createHistoricTaskLogEntryQuery().processInstanceId("testProcess"), managementService, processEngineConfiguration); }
Example #17
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogEntriesByType(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { assertThatTaskLogIsFetched(taskService, historyService.createHistoricTaskLogEntryBuilder().type("testType"), historyService.createHistoricTaskLogEntryQuery().type("testType"), managementService, processEngineConfiguration); }
Example #18
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogEntriesByScopeId(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { assertThatTaskLogIsFetched(taskService, historyService.createHistoricTaskLogEntryBuilder().scopeId("testScopeId"), historyService.createHistoricTaskLogEntryQuery().scopeId("testScopeId"), managementService, processEngineConfiguration); }
Example #19
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logAddGroup(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertThat(processInstance).isNotNull(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertThat(task).isNotNull(); try { taskService.addGroupIdentityLink(task.getId(), "newCandidateGroup", IdentityLinkType.PARTICIPANT); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(2); logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()) .type("USER_TASK_IDENTITY_LINK_ADDED") .list(); assertThat(logEntries).hasSize(1); assertThat(logEntries.get(0).getData()).contains( "\"type\":\"participant\"", "\"groupId\":\"newCandidateGroup\"" ); } } finally { taskService.complete(task.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }
Example #20
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logAddCandidateGroup(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertThat(processInstance).isNotNull(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertThat(task).isNotNull(); try { taskService.addCandidateGroup(task.getId(), "newCandidateGroup"); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(2); logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()) .type("USER_TASK_IDENTITY_LINK_ADDED") .list(); assertThat(logEntries).hasSize(1); assertThat(logEntries.get(0).getData()).contains( "\"type\":\"candidate\"", "\"groupId\":\"newCandidateGroup\"" ); } } finally { taskService.complete(task.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }
Example #21
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logAddParticipantUser(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); try { assertThat(processInstance).isNotNull(); assertThat(task).isNotNull(); taskService.addUserIdentityLink(task.getId(), "newCandidateUser", IdentityLinkType.PARTICIPANT); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(2); logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()) .type("USER_TASK_IDENTITY_LINK_ADDED") .list(); assertThat(logEntries).hasSize(1); assertThat(logEntries.get(0).getData()).contains( "\"type\":\"participant\"", "\"userId\":\"newCandidateUser\"" ); } } finally { taskService.complete(task.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }
Example #22
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logAddCandidateUser(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); try { assertThat(processInstance).isNotNull(); assertThat(task).isNotNull(); taskService.addCandidateUser(task.getId(), "newCandidateUser"); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(2); logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()) .type("USER_TASK_IDENTITY_LINK_ADDED") .list(); assertThat(logEntries).hasSize(1); assertThat(logEntries.get(0).getData()).contains( "\"type\":\"candidate\"", "\"userId\":\"newCandidateUser\"" ); } } finally { taskService.complete(task.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }
Example #23
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logProcessTaskEvents(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertThat(processInstance).isNotNull(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertThat(task).isNotNull(); try { taskService.setAssignee(task.getId(), "newAssignee"); taskService.setOwner(task.getId(), "newOwner"); taskService.complete(task.getId()); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(4); HistoricTaskLogEntry logEntry = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_CREATED").singleResult(); assertThat(logEntry).isNotNull(); assertThat(logEntry.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId()); assertThat(logEntry.getExecutionId()).isEqualTo(task.getExecutionId()); assertThat(logEntry.getProcessInstanceId()).isEqualTo(processInstance.getId()); assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_ASSIGNEE_CHANGED").count()).isEqualTo(1); assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_OWNER_CHANGED").count()).isEqualTo(1); assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_COMPLETED").count()).isEqualTo(1); } } finally { deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }
Example #24
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void createCustomTaskEventLog(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { task = taskService.createTaskBuilder().create(); Date todayDate = new Date(); HistoricTaskLogEntryBuilder historicTaskLogEntryBuilder = historyService.createHistoricTaskLogEntryBuilder(task); historicTaskLogEntryBuilder.timeStamp(todayDate); historicTaskLogEntryBuilder.userId("testUser"); historicTaskLogEntryBuilder.type("customType"); historicTaskLogEntryBuilder.data("testData"); historicTaskLogEntryBuilder.create(); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(2); logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("customType").list(); assertThat(logEntries).hasSize(1); HistoricTaskLogEntry historicTaskLogEntry = logEntries.get(0); assertThat(historicTaskLogEntry.getLogNumber()).isNotNull(); assertThat(historicTaskLogEntry.getUserId()).isEqualTo("testUser"); assertThat(historicTaskLogEntry.getTaskId()).isEqualTo(task.getId()); assertThat(historicTaskLogEntry.getType()).isEqualTo("customType"); assertThat(simpleDateFormat.format(historicTaskLogEntry.getTimeStamp())).isEqualTo(simpleDateFormat.format(todayDate)); assertThat(historicTaskLogEntry.getData()).isEqualTo("testData"); historyService.deleteHistoricTaskLogEntry(historicTaskLogEntry.getLogNumber()); } }
Example #25
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogEntriesByNativeQuery(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { assertThat(managementService.getTableName(HistoricTaskLogEntryEntity.class, false)).isEqualTo("ACT_HI_TSK_LOG"); assertThat(managementService.getTableName(HistoricTaskLogEntry.class, false)).isEqualTo("ACT_HI_TSK_LOG"); HistoricTaskLogEntryBuilder historicTaskLogEntryBuilder = historyService.createHistoricTaskLogEntryBuilder(); historicTaskLogEntryBuilder.taskId("1").create(); historicTaskLogEntryBuilder.taskId("2").create(); historicTaskLogEntryBuilder.taskId("3").create(); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { try { assertThat(historyService.createNativeHistoricTaskLogEntryQuery() .sql("SELECT * FROM " + managementService.getTableName(HistoricTaskLogEntry.class)).list()).hasSize(3); assertThat(historyService.createNativeHistoricTaskLogEntryQuery() .sql("SELECT count(*) FROM " + managementService.getTableName(HistoricTaskLogEntry.class)).count()).isEqualTo(3); assertThat(historyService.createNativeHistoricTaskLogEntryQuery().parameter("taskId", "1"). sql("SELECT count(*) FROM " + managementService.getTableName(HistoricTaskLogEntry.class) + " WHERE TASK_ID_ = #{taskId}").list()) .hasSize(1); assertThat(historyService.createNativeHistoricTaskLogEntryQuery().parameter("taskId", "1"). sql("SELECT count(*) FROM " + managementService.getTableName(HistoricTaskLogEntry.class) + " WHERE TASK_ID_ = #{taskId}").count()) .isEqualTo(1); } finally { deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, "1"); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, "2"); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, "3"); } } }
Example #26
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void queryForTaskLogOrderBy(TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { HistoricTaskLogEntryBuilder historicTaskLogEntryBuilder = historyService.createHistoricTaskLogEntryBuilder(); historicTaskLogEntryBuilder.taskId("1").timeStamp(getInsertDate()).create(); historicTaskLogEntryBuilder.taskId("2").timeStamp(getCompareAfterDate()).create(); historicTaskLogEntryBuilder.taskId("3").timeStamp(getCompareBeforeDate()).create(); try { if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> taskLogEntries = historyService.createHistoricTaskLogEntryQuery().list(); assertThat(taskLogEntries).extracting(taskLogEntry -> taskLogEntry.getTaskId()).containsExactly("1", "2", "3"); taskLogEntries = historyService.createHistoricTaskLogEntryQuery().orderByLogNumber().desc().list(); assertThat(taskLogEntries).extracting(taskLogEntry -> taskLogEntry.getTaskId()).containsExactly("3", "2", "1"); taskLogEntries = historyService.createHistoricTaskLogEntryQuery().orderByTimeStamp().desc().list(); assertThat(taskLogEntries).extracting(taskLogEntry -> taskLogEntry.getTaskId()).containsExactly("2", "1", "3"); } } finally { deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, "1"); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, "2"); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, "3"); } }
Example #27
Source File: TransactionRollbackTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void execute(DelegateExecution execution) { try { ManagementService managementService = CommandContextUtil.getProcessEngineConfiguration().getManagementService(); managementService.executeCommand((Command<Void>) commandContext -> { throw new RuntimeException("exception from service task"); }); } catch (Exception e) { e.printStackTrace(); } execution.setVariable("theVariable", "test"); }
Example #28
Source File: FlowableJupiterTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/bpmn/async/AsyncTaskTest.testAsyncTask.bpmn20.xml" }) void testWaitForJobs(FlowableTestHelper testHelper, RuntimeService runtimeService, ManagementService managementService) { // start process runtimeService.startProcessInstanceByKey("asyncTask"); // now there should be one job in the database: assertThat(managementService.createJobQuery().count()).isEqualTo(1); testHelper.waitForJobExecutorToProcessAllJobs(7000L, 500L); // the job is done assertThat(managementService.createJobQuery().count()).isZero(); }
Example #29
Source File: HandleHistoryCleanupTimerJobCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public Object execute(CommandContext commandContext) { ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); ManagementService managementService = processEngineConfiguration.getManagementService(); TimerJobService timerJobService = CommandContextUtil.getTimerJobService(commandContext); List<Job> cleanupJobs = managementService.createTimerJobQuery().handlerType(BpmnHistoryCleanupJobHandler.TYPE).list(); if (cleanupJobs.isEmpty()) { TimerJobEntity timerJob = timerJobService.createTimerJob(); timerJob.setJobType(JobEntity.JOB_TYPE_TIMER); timerJob.setRevision(1); timerJob.setJobHandlerType(BpmnHistoryCleanupJobHandler.TYPE); BusinessCalendar businessCalendar = processEngineConfiguration.getBusinessCalendarManager().getBusinessCalendar(CycleBusinessCalendar.NAME); timerJob.setDuedate(businessCalendar.resolveDuedate(processEngineConfiguration.getHistoryCleaningTimeCycleConfig())); timerJob.setRepeat(processEngineConfiguration.getHistoryCleaningTimeCycleConfig()); timerJobService.scheduleTimerJob(timerJob); } else { if (cleanupJobs.size() > 1) { for (int i = 1; i < cleanupJobs.size(); i++) { managementService.deleteTimerJob(cleanupJobs.get(i).getId()); } } } return null; }
Example #30
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logDeleteCandidateGroup(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertThat(processInstance).isNotNull(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertThat(task).isNotNull(); taskService.addCandidateGroup(task.getId(), "newCandidateGroup"); try { taskService.deleteCandidateGroup(task.getId(), "newCandidateGroup"); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(3); logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()) .type("USER_TASK_IDENTITY_LINK_REMOVED") .list(); assertThat(logEntries).hasSize(1); assertThat(logEntries.get(0).getData()).contains( "\"type\":\"candidate\"", "\"groupId\":\"newCandidateGroup\"" ); } } finally { taskService.complete(task.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }