Esempio n. 1
0
        public virtual void testQueryWithReadPermissionOnProcessInstance()
        {
            // given
            startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
            startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
            string processInstanceId = startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY).Id;

            startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
            startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
            startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
            startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);

            createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);

            // when
            IncidentQuery query = runtimeService.createIncidentQuery();

            // then
            verifyQueryResults(query, 1);

            Incident incident = query.singleResult();

            assertNotNull(incident);
            assertEquals(processInstanceId, incident.ProcessInstanceId);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetUnexistingIncident()
        public virtual void testGetUnexistingIncident()
        {
            when(mockedQuery.singleResult()).thenReturn(null);

            given().pathParam("id", MockProvider.EXAMPLE_INCIDENT_ID).then().expect().statusCode(Status.NOT_FOUND.StatusCode).when().get(SINGLE_INCIDENT_URL);

            verify(mockRuntimeService).createIncidentQuery();
            verify(mockedQuery).incidentId(MockProvider.EXAMPLE_INCIDENT_ID);
            verify(mockedQuery).singleResult();
        }
Esempio n. 3
0
        private IncidentQuery setupMockIncidentQuery(IList <Incident> incidents)
        {
            IncidentQuery sampleQuery = mock(typeof(IncidentQuery));

            when(sampleQuery.incidentId(anyString())).thenReturn(sampleQuery);
            when(sampleQuery.singleResult()).thenReturn(mock(typeof(Incident)));

            mockRuntimeService = mock(typeof(RuntimeServiceImpl));
            when(processEngine.RuntimeService).thenReturn(mockRuntimeService);
            when(mockRuntimeService.createIncidentQuery()).thenReturn(sampleQuery);

            return(sampleQuery);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByInvalidConfiguration()
        public virtual void testQueryByInvalidConfiguration()
        {
            IncidentQuery query = runtimeService.createIncidentQuery().configuration("invalid");

            assertEquals(0, query.count());

            IList <Incident> incidents = query.list();

            assertTrue(incidents.Count == 0);

            Incident incident = query.singleResult();

            assertNull(incident);
        }
Esempio n. 5
0
        public virtual void testQueryByProcessInstanceId()
        {
            IncidentQuery query = runtimeService.createIncidentQuery().processInstanceId(processInstanceIds[0]);

            assertEquals(1, query.count());

            IList <Incident> incidents = query.list();

            assertFalse(incidents.Count == 0);
            assertEquals(1, incidents.Count);

            Incident incident = query.singleResult();

            assertNotNull(incident);
        }
Esempio n. 6
0
        public virtual void testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition()
        {
            // given
            string processInstanceId = startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY).Id;

            createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);

            // when
            IncidentQuery query = runtimeService.createIncidentQuery();

            // then
            verifyQueryResults(query, 1);

            Incident incident = query.singleResult();

            assertNotNull(incident);
            assertEquals(processInstanceId, incident.ProcessInstanceId);
        }
Esempio n. 7
0
        public virtual void testQueryByRootCauseIncidentId()
        {
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callFailingCallActivity");

            testHelper.executeAvailableJobs();

            ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(processInstance.Id).singleResult();

            assertNotNull(subProcessInstance);

            ProcessInstance failingSubProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(subProcessInstance.Id).singleResult();

            assertNotNull(subProcessInstance);

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

            assertNotNull(incident);

            IncidentQuery query = runtimeService.createIncidentQuery().rootCauseIncidentId(incident.Id);

            assertEquals(3, query.count());

            IList <Incident> incidents = query.list();

            assertFalse(incidents.Count == 0);
            assertEquals(3, incidents.Count);

            try
            {
                query.singleResult();
                fail();
            }
            catch (ProcessEngineException)
            {
                // Exception is expected
            }
        }