Exemplo n.º 1
0
        public virtual void testBatchActivationByHistoricProcessInstanceQuery()
        {
            // given
            ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
            ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");

            // when
            Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.Id, processInstance2.Id))).suspendAsync();

            helper.executeSeedJob(suspendprocess);
            helper.executeJobs(suspendprocess);
            Batch activateprocess = runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.Id, processInstance2.Id))).activateAsync();

            helper.executeSeedJob(activateprocess);
            helper.executeJobs(activateprocess);


            // then
            ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.Id).singleResult();

            assertFalse(p1c.Suspended);
            ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.Id).singleResult();

            assertFalse(p2c.Suspended);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDontWriteDuplicateLogOnBatchMigrationJobExecution()
        public virtual void testDontWriteDuplicateLogOnBatchMigrationJobExecution()
        {
            // given
            ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.Id);

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            batch = runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).executeAsync();
            Job seedJob = managementService.createJobQuery().singleResult();

            managementService.executeJob(seedJob.Id);

            Job migrationJob = managementService.createJobQuery().jobDefinitionId(batch.BatchJobDefinitionId).singleResult();

            // when
            managementService.executeJob(migrationJob.Id);

            // then
            assertEquals(9, userOperationLogQuery().count());
            assertEquals(2, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE).entityType(EntityTypes.DEPLOYMENT).count());
            assertEquals(1, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE).entityType(EntityTypes.PROCESS_INSTANCE).count());
            assertEquals(3, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MIGRATE).entityType(EntityTypes.PROCESS_INSTANCE).count());
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void seedJobShouldHaveDefaultPriority()
        public virtual void seedJobShouldHaveDefaultPriority()
        {
            // when
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // then
            Job seedJob = helper.getSeedJob(batch);

            assertEquals(DefaultJobPriorityProvider.DEFAULT_PRIORITY, seedJob.Priority);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSuspendBatch()
        public virtual void shouldSuspendBatch()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // when
            managementService.suspendBatchById(batch.Id);

            // then
            batch = managementService.createBatchQuery().batchId(batch.Id).singleResult();
            assertTrue(batch.Suspended);
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateActivatedSeedJob()
        public virtual void shouldCreateActivatedSeedJob()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(2);

            // when
            helper.executeSeedJob(batch);

            // then
            Job seedJob = helper.getSeedJob(batch);

            assertFalse(seedJob.Suspended);
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpBatchQueryMock()
        public virtual void setUpBatchQueryMock()
        {
            Batch batchMock = MockProvider.createMockBatch();

            queryMock = mock(typeof(BatchQuery));
            when(queryMock.batchId(eq(MockProvider.EXAMPLE_BATCH_ID))).thenReturn(queryMock);
            when(queryMock.singleResult()).thenReturn(batchMock);

            managementServiceMock = mock(typeof(ManagementService));
            when(managementServiceMock.createBatchQuery()).thenReturn(queryMock);

            when(processEngine.ManagementService).thenReturn(managementServiceMock);
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateActivatedExecutionJobs()
        public virtual void shouldCreateActivatedExecutionJobs()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // when
            helper.executeSeedJob(batch);

            // then
            Job migrationJob = helper.getExecutionJobs(batch)[0];

            assertFalse(migrationJob.Suspended);
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void seedJobShouldGetPriorityFromProcessEngineConfiguration()
        public virtual void seedJobShouldGetPriorityFromProcessEngineConfiguration()
        {
            // given
            BatchJobPriority = CUSTOM_PRIORITY;

            // when
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // then
            Job seedJob = helper.getSeedJob(batch);

            assertEquals(CUSTOM_PRIORITY, seedJob.Priority);
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void batchExecutionJobShouldHaveDefaultPriority()
        public virtual void batchExecutionJobShouldHaveDefaultPriority()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // when
            helper.executeSeedJob(batch);

            // then
            Job executionJob = helper.getExecutionJobs(batch)[0];

            assertEquals(DefaultJobPriorityProvider.DEFAULT_PRIORITY, executionJob.Priority);
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void seedJobShouldGetPriorityFromOverridingJobDefinitionPriorityWithCascade()
        public virtual void seedJobShouldGetPriorityFromOverridingJobDefinitionPriorityWithCascade()
        {
            // given
            Batch         batch             = helper.migrateProcessInstancesAsync(1);
            JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);

            // when
            managementService.setOverridingJobPriorityForJobDefinition(seedJobDefinition.Id, CUSTOM_PRIORITY, true);

            // then
            Job seedJob = helper.getSeedJob(batch);

            assertEquals(CUSTOM_PRIORITY, seedJob.Priority);
        }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateSuspendedExecutionJobs()
        public virtual void shouldCreateSuspendedExecutionJobs()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            managementService.suspendBatchById(batch.Id);

            // when
            helper.executeSeedJob(batch);

            // then
            Job migrationJob = helper.getExecutionJobs(batch)[0];

            assertTrue(migrationJob.Suspended);
        }
Exemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void executionJobShouldGetPriorityFromOverridingJobDefinitionPriority()
        public virtual void executionJobShouldGetPriorityFromOverridingJobDefinitionPriority()
        {
            // given
            Batch         batch = helper.migrateProcessInstancesAsync(1);
            JobDefinition executionJobDefinition = helper.getExecutionJobDefinition(batch);

            managementService.setOverridingJobPriorityForJobDefinition(executionJobDefinition.Id, CUSTOM_PRIORITY, true);

            // when
            helper.executeSeedJob(batch);

            // then
            Job executionJob = helper.getExecutionJobs(batch)[0];

            assertEquals(CUSTOM_PRIORITY, executionJob.Priority);
        }
Exemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void monitorJobShouldGetPriorityOverridingJobDefinitionPriority()
        public virtual void monitorJobShouldGetPriorityOverridingJobDefinitionPriority()
        {
            // given
            Batch         batch = helper.migrateProcessInstancesAsync(1);
            JobDefinition monitorJobDefinition = helper.getMonitorJobDefinition(batch);

            managementService.setOverridingJobPriorityForJobDefinition(monitorJobDefinition.Id, CUSTOM_PRIORITY);

            // when
            helper.executeSeedJob(batch);

            // then
            Job monitorJob = helper.getMonitorJob(batch);

            assertEquals(CUSTOM_PRIORITY, monitorJob.Priority);
        }
Exemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void cleanBatch()
        public virtual void cleanBatch()
        {
            Batch batch = engineRule.ManagementService.createBatchQuery().singleResult();

            if (batch != null)
            {
                engineRule.ManagementService.deleteBatch(batch.Id, true);
            }

            HistoricBatch historicBatch = engineRule.HistoryService.createHistoricBatchQuery().singleResult();

            if (historicBatch != null)
            {
                engineRule.HistoryService.deleteHistoricBatch(historicBatch.Id);
            }
        }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void removeBatch()
        public virtual void removeBatch()
        {
            Batch batch = managementService.createBatchQuery().singleResult();

            if (batch != null)
            {
                managementService.deleteBatch(batch.Id, true);
            }

            HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult();

            if (historicBatch != null)
            {
                historyService.deleteHistoricBatch(historicBatch.Id);
            }
        }
Exemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSuspendSeedJobAndDefinition()
        public virtual void shouldSuspendSeedJobAndDefinition()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // when
            managementService.suspendBatchById(batch.Id);

            // then
            JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);

            assertTrue(seedJobDefinition.Suspended);

            Job seedJob = helper.getSeedJob(batch);

            assertTrue(seedJob.Suspended);
        }
Exemplo n.º 17
0
        public virtual void testRestartProcessInstanceAsyncWithTenantId()
        {
            // given
            ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);

            identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE));

            // when
            Batch batch = runtimeService.restartProcessInstances(processInstance.ProcessDefinitionId).startBeforeActivity("userTask").processInstanceIds(processInstance.Id).executeAsync();

            batchHelper.completeBatch(batch);

            // then
            ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active().processDefinitionId(processInstance.ProcessDefinitionId).singleResult();

            assertNotNull(restartedInstance);
            assertEquals(restartedInstance.TenantId, TENANT_ONE);
        }
Exemplo n.º 18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDontWriteDuplicateLogOnBatchDeletionJobExecution()
        public virtual void testDontWriteDuplicateLogOnBatchDeletionJobExecution()
        {
            ProcessDefinition definition      = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessInstance   processInstance = runtimeService.startProcessInstanceById(definition.Id);

            batch = runtimeService.deleteProcessInstancesAsync(Arrays.asList(processInstance.Id), null, "test reason");

            Job seedJob = managementService.createJobQuery().singleResult();

            managementService.executeJob(seedJob.Id);

            foreach (Job pending in managementService.createJobQuery().list())
            {
                managementService.executeJob(pending.Id);
            }

            assertEquals(5, userOperationLogQuery().entityTypeIn(EntityTypes.PROCESS_INSTANCE, EntityTypes.DEPLOYMENT).count());
        }
Exemplo n.º 19
0
        public virtual Batch build()
        {
            Batch batch = mock(typeof(Batch));

            when(batch.Id).thenReturn(id_Renamed);
            when(batch.Type).thenReturn(type_Renamed);
            when(batch.TotalJobs).thenReturn(totalJobs_Renamed);
            when(batch.JobsCreated).thenReturn(jobsCreated_Renamed);
            when(batch.BatchJobsPerSeed).thenReturn(batchJobsPerSeed_Renamed);
            when(batch.InvocationsPerBatchJob).thenReturn(invocationsPerBatchJob_Renamed);
            when(batch.SeedJobDefinitionId).thenReturn(seedJobDefinitionId_Renamed);
            when(batch.MonitorJobDefinitionId).thenReturn(monitorJobDefinitionId_Renamed);
            when(batch.BatchJobDefinitionId).thenReturn(batchJobDefinitionId_Renamed);
            when(batch.Suspended).thenReturn(suspended_Renamed);
            when(batch.TenantId).thenReturn(tenantId_Renamed);
            when(batch.CreateUserId).thenReturn(createUserId_Renamed);
            return(batch);
        }
Exemplo n.º 20
0
        public static BatchDto fromBatch(Batch batch)
        {
            BatchDto dto = new BatchDto();

            dto.id                     = batch.Id;
            dto.type                   = batch.Type;
            dto.totalJobs              = batch.TotalJobs;
            dto.jobsCreated            = batch.JobsCreated;
            dto.batchJobsPerSeed       = batch.BatchJobsPerSeed;
            dto.invocationsPerBatchJob = batch.InvocationsPerBatchJob;
            dto.seedJobDefinitionId    = batch.SeedJobDefinitionId;
            dto.monitorJobDefinitionId = batch.MonitorJobDefinitionId;
            dto.batchJobDefinitionId   = batch.BatchJobDefinitionId;
            dto.suspended              = batch.Suspended;
            dto.tenantId               = batch.TenantId;
            dto.createUserId           = batch.CreateUserId;
            return(dto);
        }
Exemplo n.º 21
0
        public virtual void testUserOperationLogQueryByBatchEntityType()
        {
            // given
            Batch batch1 = helper.migrateProcessInstancesAsync(1);
            Batch batch2 = helper.migrateProcessInstancesAsync(1);

            // when
            identityService.AuthenticatedUserId = USER_ID;
            managementService.suspendBatchById(batch1.Id);
            managementService.suspendBatchById(batch2.Id);
            managementService.activateBatchById(batch1.Id);
            identityService.clearAuthentication();

            // then
            UserOperationLogQuery query = historyService.createUserOperationLogQuery().entityType(BATCH);

            assertEquals(3, query.count());
            assertEquals(3, query.list().size());
        }
Exemplo n.º 22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canMigrateInstanceBetweenSameTenantCase1()
        public virtual void canMigrateInstanceBetweenSameTenantCase1()
        {
            // given
            ProcessDefinition sourceDefinition = defaultTestRule.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = defaultTestRule.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = defaultEngineRule.RuntimeService.startProcessInstanceById(sourceDefinition.Id);
            MigrationPlan   migrationPlan   = defaultEngineRule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            Batch batch = defaultEngineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).executeAsync();

            batchHelper.executeSeedJob(batch);

            // when
            batchHelper.executeJobs(batch);

            // then
            assertMigratedTo(processInstance, targetDefinition);
        }
Exemplo n.º 23
0
        public virtual void shouldCreateUserOperationLogForBatchSuspension()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            // when
            identityService.AuthenticatedUserId = USER_ID;
            managementService.suspendBatchById(batch.Id);
            identityService.clearAuthentication();

            // then
            UserOperationLogEntry entry = historyService.createUserOperationLogQuery().singleResult();

            assertNotNull(entry);
            assertEquals(batch.Id, entry.BatchId);
            assertEquals(AbstractSetBatchStateCmd.SUSPENSION_STATE_PROPERTY, entry.Property);
            assertNull(entry.OrgValue);
            assertEquals(org.camunda.bpm.engine.impl.persistence.entity.SuspensionState_Fields.SUSPENDED.Name, entry.NewValue);
        }
Exemplo n.º 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldActivateExecutionJobsAndDefinition()
        public virtual void shouldActivateExecutionJobsAndDefinition()
        {
            // given
            Batch batch = helper.migrateProcessInstancesAsync(1);

            managementService.suspendBatchById(batch.Id);
            helper.executeSeedJob(batch);

            // when
            managementService.activateBatchById(batch.Id);

            // then
            JobDefinition migrationJobDefinition = helper.getExecutionJobDefinition(batch);

            assertFalse(migrationJobDefinition.Suspended);

            Job migrationJob = helper.getExecutionJobs(batch)[0];

            assertFalse(migrationJob.Suspended);
        }
Exemplo n.º 25
0
        public virtual void testBatchSuspensionById()
        {
            // given
            ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
            ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");

            // when
            Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(Arrays.asList(processInstance1.Id, processInstance2.Id)).suspendAsync();

            helper.executeSeedJob(suspendprocess);
            helper.executeJobs(suspendprocess);


            // then
            ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.Id).singleResult();

            assertTrue(p1c.Suspended);
            ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.Id).singleResult();

            assertTrue(p2c.Suspended);
        }
Exemplo n.º 26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cannotMigrateInstanceWithoutTenantIdToDifferentTenant()
        public virtual void cannotMigrateInstanceWithoutTenantIdToDifferentTenant()
        {
            // given
            ProcessDefinition sourceDefinition = defaultTestRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = defaultTestRule.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = defaultEngineRule.RuntimeService.startProcessInstanceById(sourceDefinition.Id);
            MigrationPlan   migrationPlan   = defaultEngineRule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            Batch batch = defaultEngineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).executeAsync();

            batchHelper.executeSeedJob(batch);

            // when
            batchHelper.executeJobs(batch);

            // then
            Job migrationJob = batchHelper.getExecutionJobs(batch)[0];

            Assert.assertThat(migrationJob.ExceptionMessage, CoreMatchers.containsString("Cannot migrate process instance '" + processInstance.Id + "' without tenant to a process definition with a tenant ('tenant1')"));
        }
Exemplo n.º 27
0
        public virtual BatchDto modifyProcessInstanceAsync(ProcessInstanceModificationDto dto)
        {
            Batch batch = null;

            if (dto.Instructions != null && dto.Instructions.Count > 0)
            {
                ProcessInstanceModificationBuilder modificationBuilder = engine.RuntimeService.createProcessInstanceModification(processInstanceId);

                dto.applyTo(modificationBuilder, engine, objectMapper);

                try
                {
                    batch = modificationBuilder.executeAsync(dto.SkipCustomListeners, dto.SkipIoMappings);
                }
                catch (BadUserRequestException e)
                {
                    throw new InvalidRequestException(Status.BAD_REQUEST, e.Message);
                }
                return(BatchDto.fromBatch(batch));
            }

            throw new InvalidRequestException(Status.BAD_REQUEST, "The provided instuctions are invalid.");
        }
Exemplo n.º 28
0
 public override JobDefinition getExecutionJobDefinition(Batch batch)
 {
     return(ManagementService.createJobDefinitionQuery().jobDefinitionId(batch.BatchJobDefinitionId).jobType(org.camunda.bpm.engine.batch.Batch_Fields.TYPE_PROCESS_INSTANCE_UPDATE_SUSPENSION_STATE).singleResult());
 }