use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.
the class MigrationBoundaryEventsTest method testMigrateTimerBoundaryEventKeepTrigger.
@Test
public void testMigrateTimerBoundaryEventKeepTrigger() {
// given
BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).timerWithDuration("PT5S").userTask(AFTER_BOUNDARY_TASK).endEvent().done();
BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).timerWithDuration("PT10M").userTask(AFTER_BOUNDARY_TASK).endEvent().done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
Map<String, String> activities = new HashMap<String, String>();
activities.put(USER_TASK_ID, USER_TASK_ID);
activities.put(BOUNDARY_ID, BOUNDARY_ID);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(BOUNDARY_ID, BOUNDARY_ID).build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertJobMigrated(BOUNDARY_ID, BOUNDARY_ID, TimerExecuteNestedActivityJobHandler.TYPE);
// and it is possible to trigger the event and successfully complete the migrated instance
ManagementService managementService = rule.getManagementService();
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
testHelper.completeTask(AFTER_BOUNDARY_TASK);
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.
the class BatchHelper method setRetries.
public void setRetries(Batch batch, int count, int retries) {
List<Job> jobs = getExecutionJobs(batch);
assertTrue(jobs.size() >= count);
ManagementService managementService = getManagementService();
for (int i = 0; i < count; i++) {
managementService.setJobRetries(jobs.get(i).getId(), retries);
}
}
use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.
the class MockedProcessEngineProvider method mockServices.
private void mockServices(ProcessEngine engine) {
RepositoryService repoService = mock(RepositoryService.class);
IdentityService identityService = mock(IdentityService.class);
TaskService taskService = mock(TaskService.class);
RuntimeService runtimeService = mock(RuntimeService.class);
FormService formService = mock(FormService.class);
HistoryService historyService = mock(HistoryService.class);
ManagementService managementService = mock(ManagementService.class);
CaseService caseService = mock(CaseService.class);
FilterService filterService = mock(FilterService.class);
ExternalTaskService externalTaskService = mock(ExternalTaskService.class);
when(engine.getRepositoryService()).thenReturn(repoService);
when(engine.getIdentityService()).thenReturn(identityService);
when(engine.getTaskService()).thenReturn(taskService);
when(engine.getRuntimeService()).thenReturn(runtimeService);
when(engine.getFormService()).thenReturn(formService);
when(engine.getHistoryService()).thenReturn(historyService);
when(engine.getManagementService()).thenReturn(managementService);
when(engine.getCaseService()).thenReturn(caseService);
when(engine.getFilterService()).thenReturn(filterService);
when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.
the class JobDefinitionResourceImpl method setJobRetries.
public void setJobRetries(RetriesDto dto) {
try {
ManagementService managementService = engine.getManagementService();
managementService.setJobRetriesByJobDefinitionId(jobDefinitionId, dto.getRetries());
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.
the class JobResourceImpl method getJob.
@Override
public JobDto getJob() {
ManagementService managementService = engine.getManagementService();
Job job = managementService.createJobQuery().jobId(jobId).singleResult();
if (job == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Job with id " + jobId + " does not exist");
}
return JobDto.fromJob(job);
}
Aggregations