Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByJobDefinitionId()
        public virtual void testQueryByJobDefinitionId()
        {
            string processDefinitionId1 = testHelper.deployAndGetDefinition(FAILING_SERVICE_TASK_MODEL).Id;
            string processDefinitionId2 = testHelper.deployAndGetDefinition(FAILING_SERVICE_TASK_MODEL).Id;

            runtimeService.startProcessInstanceById(processDefinitionId1);
            runtimeService.startProcessInstanceById(processDefinitionId2);
            testHelper.executeAvailableJobs();

            string jobDefinitionId1 = managementService.createJobQuery().processDefinitionId(processDefinitionId1).singleResult().JobDefinitionId;
            string jobDefinitionId2 = managementService.createJobQuery().processDefinitionId(processDefinitionId2).singleResult().JobDefinitionId;

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().jobDefinitionIdIn(jobDefinitionId1, jobDefinitionId2);

            assertEquals(2, query.list().size());
            assertEquals(2, query.count());

            query = historyService.createHistoricIncidentQuery().jobDefinitionIdIn(jobDefinitionId1);

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());

            query = historyService.createHistoricIncidentQuery().jobDefinitionIdIn(jobDefinitionId2);

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Ejemplo n.º 2
0
        public virtual void testQueryByTenantId()
        {
            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().tenantIdIn(TENANT_ONE);

            assertThat(query.count(), @is(1L));

            query = historyService.createHistoricIncidentQuery().tenantIdIn(TENANT_TWO);

            assertThat(query.count(), @is(1L));
        }
Ejemplo n.º 3
0
        public virtual void testDoNotCreateNewIncident()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            ProcessInstance pi = runtimeService.createProcessInstanceQuery().singleResult();

            HistoricIncidentQuery query    = historyService.createHistoricIncidentQuery().processInstanceId(pi.Id);
            HistoricIncident      incident = query.singleResult();

            assertNotNull(incident);

            JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();

            // set retries to 1 by job definition id
            managementService.setJobRetriesByJobDefinitionId(jobDefinition.Id, 1);

            // the incident still exists
            HistoricIncident tmp = query.singleResult();

            assertEquals(incident.Id, tmp.Id);
            assertNull(tmp.EndTime);
            assertTrue(tmp.Open);

            // execute the available job (should fail again)
            executeAvailableJobs();

            // the incident still exists and there
            // should be not a new incident
            assertEquals(1, query.count());
            tmp = query.singleResult();
            assertEquals(incident.Id, tmp.Id);
            assertNull(tmp.EndTime);
            assertTrue(tmp.Open);
        }
Ejemplo n.º 4
0
        public virtual void testQueryNoAuthenticatedTenants()
        {
            identityService.setAuthentication("user", null, null);

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();

            assertThat(query.count(), @is(0L));
        }
Ejemplo n.º 5
0
        public virtual void testQueryByIncidentType()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().incidentType(org.camunda.bpm.engine.runtime.Incident_Fields.FAILED_JOB_HANDLER_TYPE);

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Ejemplo n.º 6
0
        public virtual void testQueryDisabledTenantCheck()
        {
            processEngineConfiguration.TenantCheckEnabled = false;
            identityService.setAuthentication("user", null, null);

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();

            assertThat(query.count(), @is(2L));
        }
Ejemplo n.º 7
0
        public virtual void testQueryByOpen()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().open();

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Ejemplo n.º 8
0
        public virtual void testQueryAuthenticatedTenants()
        {
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();

            assertThat(query.count(), @is(2L));
            assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(1L));
            assertThat(query.tenantIdIn(TENANT_TWO).count(), @is(1L));
        }
Ejemplo n.º 9
0
        private HistoricIncidentQuery setUpMockHistoricIncidentQuery(IList <HistoricIncident> mockedHistoricIncidents)
        {
            HistoricIncidentQuery mockedHistoricIncidentQuery = mock(typeof(HistoricIncidentQuery));

            when(mockedHistoricIncidentQuery.list()).thenReturn(mockedHistoricIncidents);
            when(mockedHistoricIncidentQuery.count()).thenReturn((long)mockedHistoricIncidents.Count);

            when(processEngine.HistoryService.createHistoricIncidentQuery()).thenReturn(mockedHistoricIncidentQuery);

            return(mockedHistoricIncidentQuery);
        }
Ejemplo n.º 10
0
        public virtual void testQueryByConfiguration()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            string configuration = managementService.createJobQuery().singleResult().Id;

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().configuration(configuration);

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Ejemplo n.º 11
0
        public virtual void testQueryByExecutionId()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            ProcessInstance pi = runtimeService.createProcessInstanceQuery().singleResult();

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().executionId(pi.Id);

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Ejemplo n.º 12
0
        public virtual void testQueryByIncidentId()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            string incidentId = historyService.createHistoricIncidentQuery().singleResult().Id;

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().incidentId(incidentId);

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByUnknownJobDefinitionId()
        public virtual void testQueryByUnknownJobDefinitionId()
        {
            string processDefinitionId = testHelper.deployAndGetDefinition(FAILING_SERVICE_TASK_MODEL).Id;

            runtimeService.startProcessInstanceById(processDefinitionId);
            testHelper.executeAvailableJobs();

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().jobDefinitionIdIn("unknown");

            assertEquals(0, query.list().size());
            assertEquals(0, query.count());
        }
Ejemplo n.º 14
0
        public virtual CountResultDto getHistoricIncidentsCount(UriInfo uriInfo)
        {
            HistoricIncidentQueryDto queryDto = new HistoricIncidentQueryDto(objectMapper, uriInfo.QueryParameters);
            HistoricIncidentQuery    query    = queryDto.toQuery(processEngine);

            long           count  = query.count();
            CountResultDto result = new CountResultDto();

            result.Count = count;

            return(result);
        }
Ejemplo n.º 15
0
        public virtual void testQueryByRootCauseIncidentId()
        {
            startProcessInstance("process");

            string processInstanceId = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult().Id;

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

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().rootCauseIncidentId(incident.Id);

            assertEquals(2, query.list().size());
            assertEquals(2, query.count());
        }
Ejemplo n.º 16
0
        public virtual void testQueryByResolved()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            string jobId = managementService.createJobQuery().singleResult().Id;

            managementService.setJobRetries(jobId, 1);

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().resolved();

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Ejemplo n.º 17
0
        public virtual void testQueryByDeleted()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            string processInstanceId = runtimeService.createProcessInstanceQuery().singleResult().Id;

            runtimeService.deleteProcessInstance(processInstanceId, null);

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().deleted();

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Ejemplo n.º 18
0
        public virtual void testCreateSecondHistoricIncident()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            string jobId = managementService.createJobQuery().singleResult().Id;

            managementService.setJobRetries(jobId, 1);

            executeAvailableJobs();

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();

            assertEquals(2, query.count());

            // the first historic incident has been resolved
            assertEquals(1, query.resolved().count());

            query = historyService.createHistoricIncidentQuery();
            // a new historic incident exists which is open
            assertEquals(1, query.open().count());
        }
Ejemplo n.º 19
0
        public virtual void testQueryByNonExistingTenantId()
        {
            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().tenantIdIn("nonExisting");

            assertThat(query.count(), @is(0L));
        }
Ejemplo n.º 20
0
        public virtual void testQueryWithoutTenantId()
        {
            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();

            assertThat(query.count(), @is(2L));
        }