示例#1
0
        public virtual IList <DecisionDefinitionDto> getDecisionDefinitions(UriInfo uriInfo, int?firstResult, int?maxResults)
        {
            DecisionDefinitionQueryDto    queryDto    = new DecisionDefinitionQueryDto(ObjectMapper, uriInfo.QueryParameters);
            IList <DecisionDefinitionDto> definitions = new List <DecisionDefinitionDto>();

            ProcessEngine           engine = ProcessEngine;
            DecisionDefinitionQuery query  = queryDto.toQuery(engine);

            IList <DecisionDefinition> matchingDefinitions = null;

            if (firstResult != null || maxResults != null)
            {
                matchingDefinitions = executePaginatedQuery(query, firstResult, maxResults);
            }
            else
            {
                matchingDefinitions = query.list();
            }

            foreach (DecisionDefinition definition in matchingDefinitions)
            {
                DecisionDefinitionDto def = DecisionDefinitionDto.fromDecisionDefinition(definition);
                definitions.Add(def);
            }
            return(definitions);
        }
示例#2
0
        private DecisionDefinitionQuery createMockDecisionDefinitionQuery(IList <DecisionDefinition> mockedDefinitions)
        {
            DecisionDefinitionQuery sampleDefinitionsQuery = mock(typeof(DecisionDefinitionQuery));

            when(sampleDefinitionsQuery.list()).thenReturn(mockedDefinitions);
            when(sampleDefinitionsQuery.count()).thenReturn((long)mockedDefinitions.Count);
            when(processEngine.RepositoryService.createDecisionDefinitionQuery()).thenReturn(sampleDefinitionsQuery);

            return(sampleDefinitionsQuery);
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNonExistingDecisionDefinitionRetrieval_ByKey()
        public virtual void testNonExistingDecisionDefinitionRetrieval_ByKey()
        {
            string nonExistingKey = "aNonExistingDefinitionKey";

            when(repositoryServiceMock.createDecisionDefinitionQuery().decisionDefinitionKey(nonExistingKey)).thenReturn(decisionDefinitionQueryMock);
            when(decisionDefinitionQueryMock.latestVersion()).thenReturn(decisionDefinitionQueryMock);
            when(decisionDefinitionQueryMock.singleResult()).thenReturn(null);
            when(decisionDefinitionQueryMock.list()).thenReturn(System.Linq.Enumerable.Empty <DecisionDefinition> ());

            given().pathParam("key", nonExistingKey).then().expect().statusCode(Status.NOT_FOUND.StatusCode).contentType(ContentType.JSON).body("type", @is(typeof(RestException).Name)).body("message", containsString("No matching decision definition with key: " + nonExistingKey)).when().get(SINGLE_DECISION_DEFINITION_BY_KEY_URL);
        }
示例#4
0
        public virtual void multipleDiagramResourcesProvided()
        {
            string resourcePrefix = "org/camunda/bpm/engine/test/dmn/deployment/DecisionDefinitionDeployerTest.testMultipleDecisionDiagramResource.";

            DecisionDefinitionQuery decisionDefinitionQuery = repositoryService.createDecisionDefinitionQuery();

            assertEquals(3, decisionDefinitionQuery.count());

            foreach (DecisionDefinition decisionDefinition in decisionDefinitionQuery.list())
            {
                assertEquals(resourcePrefix + decisionDefinition.Key + ".png", decisionDefinition.DiagramResourceName);
            }
        }
示例#5
0
        public virtual void testQueryByLatestWithTenantIdsIncludeDefinitionsWithoutTenantId()
        {
            // deploy a second version without tenant id
            deployment(DMN);
            // deploy a third version for tenant one
            deploymentForTenant(TENANT_ONE, DMN);
            deploymentForTenant(TENANT_ONE, DMN);

            DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_ONE, TENANT_TWO).includeDecisionDefinitionsWithoutTenantId();

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

            IDictionary <string, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list());

            assertThat(decisionDefinitionsForTenant[TENANT_ONE].Version, @is(3));
            assertThat(decisionDefinitionsForTenant[TENANT_TWO].Version, @is(1));
            assertThat(decisionDefinitionsForTenant[null].Version, @is(2));
        }
示例#6
0
        public virtual void testQueryByLatestWithTenantIds()
        {
            // deploy a second version for tenant one
            deploymentForTenant(TENANT_ONE, DMN);

            DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_ONE, TENANT_TWO).orderByTenantId().asc();

            // one definition for each tenant
            assertThat(query.count(), @is(2L));

            IDictionary <string, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list());

            assertThat(decisionDefinitionsForTenant[TENANT_ONE].Version, @is(2));
            assertThat(decisionDefinitionsForTenant[TENANT_TWO].Version, @is(1));
        }
示例#7
0
 protected internal virtual void verifyQueryResults(DecisionDefinitionQuery query, int expectedCount)
 {
     assertEquals(expectedCount, query.count());
     assertEquals(expectedCount, query.list().size());
 }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void querySorting()
        public virtual void querySorting()
        {
            DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery();

            // asc
            query.orderByDecisionDefinitionId().asc();
            verifyQueryResults(query, 4);

            query = repositoryService.createDecisionDefinitionQuery();

            query.orderByDeploymentId().asc();
            verifyQueryResults(query, 4);

            query = repositoryService.createDecisionDefinitionQuery();

            query.orderByDecisionDefinitionKey().asc();
            verifyQueryResults(query, 4);

            query = repositoryService.createDecisionDefinitionQuery();

            query.orderByDecisionDefinitionVersion().asc();
            verifyQueryResults(query, 4);

            // desc

            query = repositoryService.createDecisionDefinitionQuery();

            query.orderByDecisionDefinitionId().desc();
            verifyQueryResults(query, 4);

            query = repositoryService.createDecisionDefinitionQuery();

            query.orderByDeploymentId().desc();
            verifyQueryResults(query, 4);

            query = repositoryService.createDecisionDefinitionQuery();

            query.orderByDecisionDefinitionKey().desc();
            verifyQueryResults(query, 4);

            query = repositoryService.createDecisionDefinitionQuery();

            query.orderByDecisionDefinitionVersion().desc();
            verifyQueryResults(query, 4);

            query = repositoryService.createDecisionDefinitionQuery();

            // Typical use decision
            query.orderByDecisionDefinitionKey().asc().orderByDecisionDefinitionVersion().desc();

            IList <DecisionDefinition> decisionDefinitions = query.list();

            assertEquals(4, decisionDefinitions.Count);

            assertEquals("one", decisionDefinitions[0].Key);
            assertEquals(2, decisionDefinitions[0].Version);
            assertEquals("one", decisionDefinitions[1].Key);
            assertEquals(1, decisionDefinitions[1].Version);
            assertEquals("two", decisionDefinitions[2].Key);
            assertEquals(1, decisionDefinitions[2].Version);
        }