public DecisionDefinition build() { DecisionDefinition mockDefinition = mock(DecisionDefinition.class); when(mockDefinition.getId()).thenReturn(id); when(mockDefinition.getCategory()).thenReturn(category); when(mockDefinition.getName()).thenReturn(name); when(mockDefinition.getKey()).thenReturn(key); when(mockDefinition.getVersion()).thenReturn(version); when(mockDefinition.getResourceName()).thenReturn(resource); when(mockDefinition.getDiagramResourceName()).thenReturn(diagramResource); when(mockDefinition.getDeploymentId()).thenReturn(deploymentId); when(mockDefinition.getTenantId()).thenReturn(tenantId); when(mockDefinition.getDecisionRequirementsDefinitionId()).thenReturn(decisionRequirementsDefinitionId); when(mockDefinition.getDecisionRequirementsDefinitionKey()).thenReturn(decisionRequirementsDefinitionKey); when(mockDefinition.getVersionTag()).thenReturn(versionTag); return mockDefinition; }
public void testQueryByLatestNoTenantIdSet() { // deploy a second version for tenant one deploymentForTenant(TENANT_ONE, DMN); DecisionDefinitionQuery query = repositoryService .createDecisionDefinitionQuery() .decisionDefinitionKey(DECISION_DEFINITION_KEY) .latestVersion(); // one definition for each tenant assertThat(query.count(), is(3L)); Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list()); assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2)); assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1)); assertThat(decisionDefinitionsForTenant.get(null).getVersion(), is(1)); }
public 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)); Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list()); assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(3)); assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1)); assertThat(decisionDefinitionsForTenant.get(null).getVersion(), is(2)); }
public static DecisionDefinitionDto fromDecisionDefinition(DecisionDefinition definition) { DecisionDefinitionDto dto = new DecisionDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.decisionRequirementsDefinitionId = definition.getDecisionRequirementsDefinitionId(); dto.decisionRequirementsDefinitionKey = definition.getDecisionRequirementsDefinitionKey(); dto.tenantId = definition.getTenantId(); dto.historyTimeToLive = definition.getHistoryTimeToLive(); dto.versionTag = definition.getVersionTag(); return dto; }
public 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)); Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list()); assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2)); assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1)); }
public static DecisionDefinitionDto fromDecisionDefinition(DecisionDefinition definition) { DecisionDefinitionDto dto = new DecisionDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.decisionRequirementsDefinitionId = definition.getDecisionRequirementsDefinitionId(); dto.decisionRequirementsDefinitionKey = definition.getDecisionRequirementsDefinitionKey(); dto.tenantId = definition.getTenantId(); dto.historyTimeToLive = definition.getHistoryTimeToLive(); dto.versionTag = definition.getVersionTag(); return dto; }
public void testQueryByLatestWithoutTenantId() { // deploy a second version without tenant id deployment(DMN); DecisionDefinitionQuery query = repositoryService .createDecisionDefinitionQuery() .decisionDefinitionKey(DECISION_DEFINITION_KEY) .latestVersion() .withoutTenantId(); assertThat(query.count(), is(1L)); DecisionDefinition decisionDefinition = query.singleResult(); assertThat(decisionDefinition.getTenantId(), is(nullValue())); assertThat(decisionDefinition.getVersion(), is(2)); }
public static DecisionDefinitionDto fromDecisionDefinition(DecisionDefinition definition) { DecisionDefinitionDto dto = new DecisionDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.decisionRequirementsDefinitionId = definition.getDecisionRequirementsDefinitionId(); dto.decisionRequirementsDefinitionKey = definition.getDecisionRequirementsDefinitionKey(); dto.tenantId = definition.getTenantId(); dto.historyTimeToLive = definition.getHistoryTimeToLive(); dto.versionTag = definition.getVersionTag(); return dto; }
public void testQueryByLatestWithTenantId() { // deploy a second version for tenant one deploymentForTenant(TENANT_ONE, DMN); DecisionDefinitionQuery query = repositoryService .createDecisionDefinitionQuery() .decisionDefinitionKey(DECISION_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); DecisionDefinition decisionDefinition = query.singleResult(); assertThat(decisionDefinition.getTenantId(), is(TENANT_ONE)); assertThat(decisionDefinition.getVersion(), is(2)); query = repositoryService .createDecisionDefinitionQuery() .decisionDefinitionKey(DECISION_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); decisionDefinition = query.singleResult(); assertThat(decisionDefinition.getTenantId(), is(TENANT_TWO)); assertThat(decisionDefinition.getVersion(), is(1)); }
@Test public void deployDecisionIndependentFromDrd() { String deploymentIdDecision = testRule.deploy(DMN_SCORE_RESOURCE).getId(); String deploymentIdDrd = testRule.deploy(DRD_SCORE_RESOURCE).getId(); // there should be one decision requirements definition DecisionRequirementsDefinitionQuery query = repositoryService.createDecisionRequirementsDefinitionQuery(); assertEquals(1, query.count()); DecisionRequirementsDefinition decisionRequirementsDefinition = query.singleResult(); assertEquals(1, decisionRequirementsDefinition.getVersion()); assertEquals(deploymentIdDrd, decisionRequirementsDefinition.getDeploymentId()); // and two deployed decisions with different versions List<DecisionDefinition> decisions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey("score-decision") .orderByDecisionDefinitionVersion().asc() .list(); assertEquals(2, decisions.size()); DecisionDefinition firstDecision = decisions.get(0); assertEquals(1, firstDecision.getVersion()); assertEquals(deploymentIdDecision, firstDecision.getDeploymentId()); assertNull(firstDecision.getDecisionRequirementsDefinitionId()); DecisionDefinition secondDecision = decisions.get(1); assertEquals(2, secondDecision.getVersion()); assertEquals(deploymentIdDrd, secondDecision.getDeploymentId()); assertEquals(decisionRequirementsDefinition.getId(),secondDecision.getDecisionRequirementsDefinitionId()); }
assertTrue(decisionDefinition.getId().startsWith("one:1")); assertEquals("Examples", decisionDefinition.getCategory()); assertEquals(1, decisionDefinition.getVersion()); assertEquals("org/camunda/bpm/engine/test/repository/one.dmn", decisionDefinition.getResourceName()); assertEquals(firstDeploymentId, decisionDefinition.getDeploymentId()); assertTrue(decisionDefinition.getId().startsWith("one:2")); assertEquals("Examples", decisionDefinition.getCategory()); assertEquals(2, decisionDefinition.getVersion()); assertEquals("org/camunda/bpm/engine/test/repository/one.dmn", decisionDefinition.getResourceName()); assertEquals(secondDeploymentId, decisionDefinition.getDeploymentId()); assertTrue(decisionDefinition.getId().startsWith("two:1")); assertEquals("Examples2", decisionDefinition.getCategory()); assertEquals(1, decisionDefinition.getVersion()); assertEquals("org/camunda/bpm/engine/test/repository/two.dmn", decisionDefinition.getResourceName()); assertEquals(firstDeploymentId, decisionDefinition.getDeploymentId());
assertEquals(2, decisionDefinitions.get(0).getVersion()); assertEquals("one", decisionDefinitions.get(1).getKey()); assertEquals(1, decisionDefinitions.get(1).getVersion()); assertEquals("two", decisionDefinitions.get(2).getKey()); assertEquals(1, decisionDefinitions.get(2).getVersion());
@Test @Deployment(resources = DMN_FILE) public void evaluateDecisionByKeyAndVersion() { // given DecisionDefinition decisionDefinition = engineRule.getRepositoryService().createDecisionDefinitionQuery().singleResult(); // when authRule.init(scenario).withUser("userId").bindResource("decisionDefinitionKey", DECISION_DEFINITION_KEY).start(); DmnDecisionTableResult decisionResult = engineRule.getDecisionService().evaluateDecisionTableByKeyAndVersion(decisionDefinition.getKey(), decisionDefinition.getVersion(), createVariables()); // then if (authRule.assertScenario(scenario)) { assertThatDecisionHasExpectedResult(decisionResult); } }
@Test public void dmnDeploymentWithDmnSuffix() { String deploymentId = testRule.deploy(DMN_CHECK_ORDER_RESOURCE_DMN_SUFFIX).getId(); // there should be one deployment DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery(); assertEquals(1, deploymentQuery.count()); // there should be one case definition DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery(); assertEquals(1, query.count()); DecisionDefinition decisionDefinition = query.singleResult(); assertTrue(decisionDefinition.getId().startsWith("decision:1:")); assertEquals("http://camunda.org/schema/1.0/dmn", decisionDefinition.getCategory()); assertEquals("CheckOrder", decisionDefinition.getName()); assertEquals("decision", decisionDefinition.getKey()); assertEquals(1, decisionDefinition.getVersion()); assertEquals(DMN_CHECK_ORDER_RESOURCE_DMN_SUFFIX, decisionDefinition.getResourceName()); assertEquals(deploymentId, decisionDefinition.getDeploymentId()); assertNull(decisionDefinition.getDiagramResourceName()); }
@Test public void dmnDeploymentWithDecisionLiteralExpression() { String deploymentId = testRule.deploy(DMN_DECISION_LITERAL_EXPRESSION).getId(); // there should be decision deployment DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery(); assertEquals(1, deploymentQuery.count()); // there should be one decision definition DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery(); assertEquals(1, query.count()); DecisionDefinition decisionDefinition = query.singleResult(); assertTrue(decisionDefinition.getId().startsWith("decisionLiteralExpression:1:")); assertEquals("http://camunda.org/schema/1.0/dmn", decisionDefinition.getCategory()); assertEquals("decisionLiteralExpression", decisionDefinition.getKey()); assertEquals("Decision with Literal Expression", decisionDefinition.getName()); assertEquals(1, decisionDefinition.getVersion()); assertEquals(DMN_DECISION_LITERAL_EXPRESSION, decisionDefinition.getResourceName()); assertEquals(deploymentId, decisionDefinition.getDeploymentId()); assertNull(decisionDefinition.getDiagramResourceName()); }
@Test public void dmnDeployment() { String deploymentId = testRule.deploy(DMN_CHECK_ORDER_RESOURCE).getId(); // there should be decision deployment DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery(); assertEquals(1, deploymentQuery.count()); // there should be one decision definition DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery(); assertEquals(1, query.count()); DecisionDefinition decisionDefinition = query.singleResult(); assertTrue(decisionDefinition.getId().startsWith("decision:1:")); assertEquals("http://camunda.org/schema/1.0/dmn", decisionDefinition.getCategory()); assertEquals("CheckOrder", decisionDefinition.getName()); assertEquals("decision", decisionDefinition.getKey()); assertEquals(1, decisionDefinition.getVersion()); assertEquals(DMN_CHECK_ORDER_RESOURCE, decisionDefinition.getResourceName()); assertEquals(deploymentId, decisionDefinition.getDeploymentId()); assertNull(decisionDefinition.getDiagramResourceName()); }
public void testQueryByLatestNoTenantIdSet() { // deploy a second version for tenant one deploymentForTenant(TENANT_ONE, DMN); DecisionDefinitionQuery query = repositoryService .createDecisionDefinitionQuery() .decisionDefinitionKey(DECISION_DEFINITION_KEY) .latestVersion(); // one definition for each tenant assertThat(query.count(), is(3L)); Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list()); assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2)); assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1)); assertThat(decisionDefinitionsForTenant.get(null).getVersion(), is(1)); }
public 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)); Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list()); assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2)); assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1)); }
public void testQueryByLatestWithoutTenantId() { // deploy a second version without tenant id deployment(DMN); DecisionDefinitionQuery query = repositoryService .createDecisionDefinitionQuery() .decisionDefinitionKey(DECISION_DEFINITION_KEY) .latestVersion() .withoutTenantId(); assertThat(query.count(), is(1L)); DecisionDefinition decisionDefinition = query.singleResult(); assertThat(decisionDefinition.getTenantId(), is(nullValue())); assertThat(decisionDefinition.getVersion(), is(2)); }
@Test @Deployment(resources = DMN_FILE) public void evaluateDecisionByKeyAndVersion() { // given DecisionDefinition decisionDefinition = engineRule.getRepositoryService().createDecisionDefinitionQuery().singleResult(); // when authRule.init(scenario).withUser("userId").bindResource("decisionDefinitionKey", DECISION_DEFINITION_KEY).start(); DmnDecisionTableResult decisionResult = engineRule.getDecisionService().evaluateDecisionTableByKeyAndVersion(decisionDefinition.getKey(), decisionDefinition.getVersion(), createVariables()); // then if (authRule.assertScenario(scenario)) { assertThatDecisionHasExpectedResult(decisionResult); } }