public void testPropagateTenantIdToIntermediateTimerJob() { deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .intermediateCatchEvent() .timerWithDuration("PT1M") .endEvent() .done()); startProcessInstance(PROCESS_DEFINITION_KEY); // the job is created when the timer event is reached Job job = managementService.createJobQuery().singleResult(); assertThat(job, is(notNullValue())); // inherit the tenant id from job definition assertThat(job.getTenantId(), is(TENANT_ID)); }
@Test public void propagateTenantIdToIntermediateTimerJob() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .intermediateCatchEvent() .timerWithDuration("PT1M") .endEvent() .done()); engineRule.getRuntimeService().startProcessInstanceByKey("process"); // the job is created when the timer event is reached Job job = engineRule.getManagementService().createJobQuery().singleResult(); assertThat(job, is(notNullValue())); // inherit the tenant id from execution assertThat(job.getTenantId(), is(TENANT_ID)); }
/** * On execution, the MockProcess will wait on a timer which is configured with an ISO 8601 duration. * E.g.: PT60S ... will wait for 60 sec * * @param iso8601duration * @return */ public CallActivityMock onExecutionWaitForTimerWithDuration(final String iso8601duration) { flowNodeBuilder = flowNodeBuilder.intermediateCatchEvent() .timerWithDuration(iso8601duration); return this; }
@Test public void setAuthenticatedTenantForIntermediateTimerEvent() { testRule.deployForTenant(TENANT_ID, Bpmn.createExecutableProcess("process") .startEvent() .intermediateCatchEvent() .timerWithDuration("PT1M") .serviceTask() .camundaClass(AssertingJavaDelegate.class.getName()) .endEvent() .done()); ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process"); AssertingJavaDelegate.addAsserts(hasAuthenticatedTenantId(TENANT_ID)); ClockUtil.setCurrentTime(tomorrow()); testRule.waitForJobExecutorToProcessAllJobs(); testRule.assertProcessEnded(processInstance.getId()); }
.startEvent() .intermediateCatchEvent("timerCatch") .timerWithDuration("PT50M") .userTask("userTask") .endEvent()
@Test public void testMigrateJobPreserveTimerConfiguration() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.newModel() .startEvent() .intermediateCatchEvent("timerCatch") .timerWithDuration("PT50M") .userTask("userTask") .endEvent() .done()); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("timerCatch", "timerCatch") .build(); // when ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan); // then testHelper.assertJobMigrated( // this also asserts that the due has not changed testHelper.snapshotBeforeMigration.getJobs().get(0), "timerCatch"); // and it is possible to trigger the event Job jobAfterMigration = testHelper.snapshotAfterMigration.getJobs().get(0); rule.getManagementService().executeJob(jobAfterMigration.getId()); testHelper.completeTask("userTask"); testHelper.assertProcessEnded(processInstance.getId()); }
@Test public void testMigrateGatewayRemoveTimerEvent() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS) .flowNodeBuilder("eventBasedGateway") .intermediateCatchEvent("oldTimerCatch") .timerWithDuration("PT50M") .endEvent() .done()); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("eventBasedGateway", "eventBasedGateway") .mapActivities("timerCatch", "timerCatch") .build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then testHelper.assertIntermediateTimerJobRemoved("oldTimerCatch"); testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch"); }
@Test public void testMigrateGatewayAddTimerEvent() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS) .flowNodeBuilder("eventBasedGateway") .intermediateCatchEvent("newTimerCatch") .timerWithDuration("PT50M") .userTask("afterNewTimerCatch") .endEvent() .done()); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("eventBasedGateway", "eventBasedGateway") .mapActivities("timerCatch", "timerCatch") .build(); // when ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan); // then testHelper.assertIntermediateTimerJobCreated("newTimerCatch"); testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch"); Job newTimerJob = rule.getManagementService().createJobQuery().activityId("newTimerCatch").singleResult(); rule.getManagementService().executeJob(newTimerJob.getId()); testHelper.completeTask("afterNewTimerCatch"); testHelper.assertProcessEnded(processInstance.getId()); }
@Test public void testCompletingSuspendedJobDuringRunningInstance() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .receiveTask() .intermediateCatchEvent() .timerWithDuration("PT0M") .endEvent() .done()); // given // a process definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running instance ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId()); // suspend the process definition (and the job definitions) repositoryService.suspendProcessDefinitionById(processDefinition.getId()); // assert that there still exists a running and active process instance assertEquals(1, runtimeService.createProcessInstanceQuery().active().count()); // when runtimeService.signal(processInstance.getId()); // then // there should be one suspended job assertEquals(1, managementService.createJobQuery().suspended().count()); assertEquals(0, managementService.createJobQuery().active().count()); assertEquals(1, runtimeService.createProcessInstanceQuery().active().count()); }
public void testPropagateTenantIdToIntermediateTimerJob() { deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .intermediateCatchEvent() .timerWithDuration("PT1M") .endEvent() .done()); startProcessInstance(PROCESS_DEFINITION_KEY); // the job is created when the timer event is reached Job job = managementService.createJobQuery().singleResult(); assertThat(job, is(notNullValue())); // inherit the tenant id from job definition assertThat(job.getTenantId(), is(TENANT_ID)); }
@Test public void propagateTenantIdToIntermediateTimerJob() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .intermediateCatchEvent() .timerWithDuration("PT1M") .endEvent() .done()); engineRule.getRuntimeService().startProcessInstanceByKey("process"); // the job is created when the timer event is reached Job job = engineRule.getManagementService().createJobQuery().singleResult(); assertThat(job, is(notNullValue())); // inherit the tenant id from execution assertThat(job.getTenantId(), is(TENANT_ID)); }
@Test public void setAuthenticatedTenantForIntermediateTimerEvent() { testRule.deployForTenant(TENANT_ID, Bpmn.createExecutableProcess("process") .startEvent() .intermediateCatchEvent() .timerWithDuration("PT1M") .serviceTask() .camundaClass(AssertingJavaDelegate.class.getName()) .endEvent() .done()); ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process"); AssertingJavaDelegate.addAsserts(hasAuthenticatedTenantId(TENANT_ID)); ClockUtil.setCurrentTime(tomorrow()); testRule.waitForJobExecutorToProcessAllJobs(); testRule.assertProcessEnded(processInstance.getId()); }
.startEvent() .intermediateCatchEvent("timerCatch") .timerWithDuration("PT50M") .userTask("userTask") .endEvent()
@Test public void testMigrateJobPreserveTimerConfiguration() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.newModel() .startEvent() .intermediateCatchEvent("timerCatch") .timerWithDuration("PT50M") .userTask("userTask") .endEvent() .done()); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("timerCatch", "timerCatch") .build(); // when ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan); // then testHelper.assertJobMigrated( // this also asserts that the due has not changed testHelper.snapshotBeforeMigration.getJobs().get(0), "timerCatch"); // and it is possible to trigger the event Job jobAfterMigration = testHelper.snapshotAfterMigration.getJobs().get(0); rule.getManagementService().executeJob(jobAfterMigration.getId()); testHelper.completeTask("userTask"); testHelper.assertProcessEnded(processInstance.getId()); }
@Test public void testMigrateGatewayRemoveTimerEvent() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS) .flowNodeBuilder("eventBasedGateway") .intermediateCatchEvent("oldTimerCatch") .timerWithDuration("PT50M") .endEvent() .done()); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("eventBasedGateway", "eventBasedGateway") .mapActivities("timerCatch", "timerCatch") .build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then testHelper.assertIntermediateTimerJobRemoved("oldTimerCatch"); testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch"); }
@Test public void testMigrateGatewayAddTimerEvent() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS) .flowNodeBuilder("eventBasedGateway") .intermediateCatchEvent("newTimerCatch") .timerWithDuration("PT50M") .userTask("afterNewTimerCatch") .endEvent() .done()); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("eventBasedGateway", "eventBasedGateway") .mapActivities("timerCatch", "timerCatch") .build(); // when ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan); // then testHelper.assertIntermediateTimerJobCreated("newTimerCatch"); testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch"); Job newTimerJob = rule.getManagementService().createJobQuery().activityId("newTimerCatch").singleResult(); rule.getManagementService().executeJob(newTimerJob.getId()); testHelper.completeTask("afterNewTimerCatch"); testHelper.assertProcessEnded(processInstance.getId()); }
@Test public void testCompletingSuspendedJobDuringRunningInstance() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .receiveTask() .intermediateCatchEvent() .timerWithDuration("PT0M") .endEvent() .done()); // given // a process definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running instance ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId()); // suspend the process definition (and the job definitions) repositoryService.suspendProcessDefinitionById(processDefinition.getId()); // assert that there still exists a running and active process instance assertEquals(1, runtimeService.createProcessInstanceQuery().active().count()); // when runtimeService.signal(processInstance.getId()); // then // there should be one suspended job assertEquals(1, managementService.createJobQuery().suspended().count()); assertEquals(0, managementService.createJobQuery().active().count()); assertEquals(1, runtimeService.createProcessInstanceQuery().active().count()); }