示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogIncidentResolution()
        public virtual void shouldLogIncidentResolution()
        {
            // given
            testRule.deploy(ProcessModels.TWO_TASKS_PROCESS);
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
            Incident        incident        = runtimeService.createIncident("foo", processInstance.Id, "userTask1", "bar");

            assertEquals(0, historyService.createUserOperationLogQuery().count());

            // when
            identityService.AuthenticatedUserId = "userId";
            runtimeService.resolveIncident(incident.Id);
            identityService.clearAuthentication();

            // then
            assertEquals(1, historyService.createUserOperationLogQuery().count());
            UserOperationLogEntry entry = historyService.createUserOperationLogQuery().singleResult();

            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_RESOLVE, entry.OperationType);
            assertEquals(EntityTypes.PROCESS_INSTANCE, entry.EntityType);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, entry.Category);
            assertEquals("incidentId", entry.Property);
            assertNull(entry.OrgValue);
            assertEquals(incident.Id, entry.NewValue);
            assertNull(entry.ExecutionId);
            assertEquals(processInstance.Id, entry.ProcessInstanceId);
            assertEquals(processInstance.ProcessDefinitionId, entry.ProcessDefinitionId);
            assertEquals("Process", entry.ProcessDefinitionKey);
        }
示例#2
0
        public virtual void testCallActivityExternalTaskIncidentMigration()
        {
            // Given we create a new process instance
            ProcessDefinition callingProcess  = engineRule.RepositoryService.createProcessDefinitionQuery().processDefinitionKey("callingProcess").singleResult();
            ProcessInstance   processInstance = engineRule.RuntimeService.startProcessInstanceById(callingProcess.Id);

            LockedExternalTask task = engineRule.ExternalTaskService.fetchAndLock(1, "foo").topic("foo", 1000L).execute()[0];

            // creating an incident in the called and calling process
            engineRule.ExternalTaskService.handleFailure(task.Id, "foo", "error", 0, 1000L);

            Incident incidentInCallingProcess = engineRule.RuntimeService.createIncidentQuery().processDefinitionId(callingProcess.Id).singleResult();

            // when
            ProcessDefinition callingProcessV2 = engineRule.RepositoryService.createProcessDefinitionQuery().processDefinitionKey("callingProcessV2").singleResult();

            MigrationPlan migrationPlan = engineRule.RuntimeService.createMigrationPlan(callingProcess.Id, callingProcessV2.Id).mapEqualActivities().mapActivities("CallActivity", "CallActivityV2").build();

            engineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(processInstance.Id).execute();

            // then
            Incident incidentAfterMigration = engineRule.RuntimeService.createIncidentQuery().incidentId(incidentInCallingProcess.Id).singleResult();

            Assert.assertEquals(callingProcessV2.Id, incidentAfterMigration.ProcessDefinitionId);
            Assert.assertEquals("CallActivityV2", incidentAfterMigration.ActivityId);
        }
示例#3
0
	  public virtual Void execute(CommandContext commandContext)
	  {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.runtime.Incident incident = commandContext.getIncidentManager().findIncidentById(incidentId);
		Incident incident = commandContext.IncidentManager.findIncidentById(incidentId);

		EnsureUtil.ensureNotNull(typeof(NotFoundException), "Cannot find an incident with id '" + incidentId + "'", "incident", incident);

		if (incident.IncidentType.Equals("failedJob") || incident.IncidentType.Equals("failedExternalTask"))
		{
		  throw new BadUserRequestException("Cannot resolve an incident of type " + incident.IncidentType);
		}

		EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "", "executionId", incident.ExecutionId);
		ExecutionEntity execution = commandContext.ExecutionManager.findExecutionById(incident.ExecutionId);

		EnsureUtil.ensureNotNull(typeof(BadUserRequestException), "Cannot find an execution for an incident with id '" + incidentId + "'", "execution", execution);

		foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
		{
		  checker.checkUpdateProcessInstance(execution);
		}

		commandContext.OperationLogManager.logProcessInstanceOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_RESOLVE, execution.ProcessInstanceId, execution.ProcessDefinitionId, null, Collections.singletonList(new PropertyChange("incidentId", null, incidentId)));

		execution.resolveIncident(incidentId);
		return null;
	  }
示例#4
0
        public virtual void historicIncidentRemainsOpenAfterMigration()
        {
            // Given we create a new process instance
            ProcessDefinition process1        = engineRule.RepositoryService.createProcessDefinitionQuery().processDefinitionKey("calledProcess").singleResult();
            ProcessInstance   processInstance = engineRule.RuntimeService.startProcessInstanceById(process1.Id);

            LockedExternalTask task = engineRule.ExternalTaskService.fetchAndLock(1, "foo").topic("foo", 1000L).execute()[0];

            engineRule.ExternalTaskService.handleFailure(task.Id, "foo", "error", 0, 1000L);

            Incident incidentInProcess = engineRule.RuntimeService.createIncidentQuery().processDefinitionId(process1.Id).singleResult();

            // when
            ProcessDefinition process2 = engineRule.RepositoryService.createProcessDefinitionQuery().processDefinitionKey("calledProcessV2").singleResult();

            MigrationPlan migrationPlan = engineRule.RuntimeService.createMigrationPlan(process1.Id, process2.Id).mapEqualActivities().mapActivities("ServiceTask_1p58ywb", "ServiceTask_V2").build();

            engineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(processInstance.Id).execute();

            // then
            HistoricIncident historicIncidentAfterMigration = engineRule.HistoryService.createHistoricIncidentQuery().singleResult();

            assertNotNull(historicIncidentAfterMigration);
            assertNull(historicIncidentAfterMigration.EndTime);
            assertTrue(historicIncidentAfterMigration.Open);

            HistoricProcessInstance historicProcessInstanceAfterMigration = engineRule.HistoryService.createHistoricProcessInstanceQuery().withIncidents().incidentStatus("open").singleResult();

            assertNotNull(historicProcessInstanceAfterMigration);

            Incident incidentAfterMigration = engineRule.RuntimeService.createIncidentQuery().incidentId(incidentInProcess.Id).singleResult();

            assertEquals(process2.Id, incidentAfterMigration.ProcessDefinitionId);
            assertEquals("ServiceTask_V2", incidentAfterMigration.ActivityId);
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCustomIncidentMigrationWithoutConfiguration()
        public virtual void testCustomIncidentMigrationWithoutConfiguration()
        {
            // given
            RuntimeService    runtimeService = engineRule.RuntimeService;
            BpmnModelInstance instance1      = Bpmn.createExecutableProcess("process1").startEvent().userTask("u1").endEvent().done();
            BpmnModelInstance instance2      = Bpmn.createExecutableProcess("process2").startEvent().userTask("u2").endEvent().done();

            testHelper.deploy(instance1, instance2);

            ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
            ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process2");

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(processInstance1.ProcessDefinitionId, processInstance2.ProcessDefinitionId).mapActivities("u1", "u2").build();

            runtimeService.createIncident("custom", processInstance1.Id, null);

            // when
            runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.Id).execute();

            // then
            Incident incident = runtimeService.createIncidentQuery().singleResult();

            assertEquals(processInstance2.ProcessDefinitionId, incident.ProcessDefinitionId);
            assertEquals("custom", incident.IncidentType);
            assertEquals(processInstance1.Id, incident.ExecutionId);
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testJobIncidentMigration()
        public virtual void testJobIncidentMigration()
        {
            // Given we deploy process definitions
            testHelper.deploy(FAIL_CALLED_PROC, NEW_CALLED_PROC);

            ProcessDefinition failingProcess = engineRule.RepositoryService.createProcessDefinitionQuery().processDefinitionKey(FAIL_CALLED_PROC_KEY).singleResult();

            ProcessDefinition newProcess = engineRule.RepositoryService.createProcessDefinitionQuery().processDefinitionKey(NEW_CALLED_PROC_KEY).singleResult();

            //create process instance and execute job which fails
            ProcessInstance processInstance = engineRule.RuntimeService.startProcessInstanceByKey(FAIL_CALLED_PROC_KEY);

            testHelper.executeAvailableJobs();

            Incident incidentInCallingProcess = engineRule.RuntimeService.createIncidentQuery().processDefinitionId(failingProcess.Id).singleResult();

            // when
            MigrationPlan migrationPlan = engineRule.RuntimeService.createMigrationPlan(failingProcess.Id, newProcess.Id).mapEqualActivities().mapActivities("task", "taskV2").build();

            engineRule.RuntimeService.newMigration(migrationPlan).processInstanceIds(processInstance.Id).execute();

            // then
            Incident incidentAfterMigration = engineRule.RuntimeService.createIncidentQuery().incidentId(incidentInCallingProcess.Id).singleResult();

            Assert.assertEquals(newProcess.Id, incidentAfterMigration.ProcessDefinitionId);
            Assert.assertEquals("taskV2", incidentAfterMigration.ActivityId);
        }
示例#7
0
 public IncidentContext(Incident incident)
 {
     this.processDefinitionId = incident.ProcessDefinitionId;
     this.activityId          = incident.ActivityId;
     this.executionId         = incident.ExecutionId;
     this.configuration       = incident.Configuration;
     this.tenantId            = incident.TenantId;
     this.jobDefinitionId     = incident.JobDefinitionId;
 }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testOriginalExceptionFromEjbReachesCaller()
        public virtual void testOriginalExceptionFromEjbReachesCaller()
        {
            runtimeService.startProcessInstanceByKey("callProcessWithExceptionFromEjb");
            Job job = managementService.createJobQuery().singleResult();

            managementService.setJobRetries(job.Id, 1);

            waitForJobExecutorToProcessAllJobs();

            Incident incident = runtimeService.createIncidentQuery().activityId("servicetask1").singleResult();

            assertThat(incident.IncidentMessage, @is("error"));
        }
示例#9
0
        public virtual void testIncidentTimestampConversion()
        {
            // given
            string processInstanceId = managementService.createJobQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).noRetriesLeft().singleResult().ProcessInstanceId;

            // when
            Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstanceId).singleResult();

            // assume
            assertNotNull(incident);

            // then
            assertThat(incident.IncidentTimestamp, @is(TIMESTAMP));
        }
示例#10
0
        public virtual IncidentDto createIncident(CreateIncidentDto createIncidentDto)
        {
            Incident newIncident = null;

            try
            {
                newIncident = engine.RuntimeService.createIncident(createIncidentDto.IncidentType, executionId, createIncidentDto.Configuration, createIncidentDto.Message);
            }
            catch (BadUserRequestException e)
            {
                throw new InvalidRequestException(Status.BAD_REQUEST, e.Message);
            }
            return(IncidentDto.fromIncident(newIncident));
        }
示例#11
0
        public virtual void testIncidentTimestampConversion()
        {
            // given
            string processInstanceId = rule.jobQuery().singleResult().ProcessInstanceId;

            // when
            Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstanceId).singleResult();

            // assume
            assertNotNull(incident);

            long incidentCount = runtimeService.createIncidentQuery().processInstanceId(processInstanceId).count();

            // then
            assertThat(incident.IncidentTimestamp, @is(TIMESTAMP));
        }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateGatewayWithIncident()
        public virtual void testMigrateGatewayWithIncident()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("timerCatch", "timerCatch").build();

            ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(migrationPlan.SourceProcessDefinitionId);

            Job timerJob = rule.ManagementService.createJobQuery().singleResult();

            // create an incident
            rule.ManagementService.setJobRetries(timerJob.Id, 0);
            Incident incidentBeforeMigration = rule.RuntimeService.createIncidentQuery().singleResult();

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then job and incident still exist
            testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch");

            Job jobAfterMigration = testHelper.snapshotAfterMigration.Jobs[0];

            Incident incidentAfterMigration = rule.RuntimeService.createIncidentQuery().singleResult();

            assertNotNull(incidentAfterMigration);

            assertEquals(incidentBeforeMigration.Id, incidentAfterMigration.Id);
            assertEquals(jobAfterMigration.Id, incidentAfterMigration.Configuration);

            assertEquals("timerCatch", incidentAfterMigration.ActivityId);
            assertEquals(targetProcessDefinition.Id, incidentAfterMigration.ProcessDefinitionId);

            // and it is possible to complete the process
            rule.ManagementService.executeJob(jobAfterMigration.Id);

            testHelper.completeTask("afterTimerCatch");
            testHelper.assertProcessEnded(processInstance.Id);
        }