Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#95 decision service #231

Merged
merged 2 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/introduction/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ but still provide an alternative implementation for some methods.
## HistoryService

* Historic process instance query: `#createHistoricProcessInstanceQuery()`

## DecisionService

* Evaluate decision: `#evaluateDecisionById()`,`#evaluateDecisionByKey()`
* Evaluate decision table: `#evaluateDecisionTableById()`,`#evaluateDecisionTableByKey()`.`#evaluateDecisionTableByKeyAndVersion()`
4 changes: 4 additions & 0 deletions docs/user-guide/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ feign:
url: "http://localhost:8083/engine-rest/"
variableInstance:
url: "http://localhost:8083/engine-rest/"
decisionDefinition:
url: "http://localhost:8083/engine-rest/"
```

To run this example, you will need the server part from the next example. To activate the server part only, please
Expand Down Expand Up @@ -154,5 +156,7 @@ feign:
url: "http://localhost:8083/engine-rest/"
variableInstance:
url: "http://localhost:8083/engine-rest/"
decisionDefinition:
url: "http://localhost:8083/engine-rest/"
```

8 changes: 8 additions & 0 deletions docs/user-guide/support-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,11 @@ Here are currently implemented methods. The version behind the service name deno
## HistoryService @ 0.0.7

* `# createHistoricProcessInstanceQuery`

## DecisionService @ 7.17.3

* `# evaluateDecisionById`
* `# evaluateDecisionByKey`
* `# evaluateDecisionTableById`
* `# evaluateDecisionTableByKey`
* `# evaluateDecisionTableByKeyAndVersion`
2 changes: 2 additions & 0 deletions examples/example-provided/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ feign:
url: "http://localhost:${server.port}/engine-rest/"
variableInstance:
url: "http://localhost:${server.port}/engine-rest/"
decisionDefinition:
url: "http://localhost:${server.port}/engine-rest/"

logging:
level:
Expand Down
3 changes: 2 additions & 1 deletion examples/example/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ feign:
url: "http://localhost:8083/engine-rest/"
variableInstance:
url: "http://localhost:8083/engine-rest/"

decisionDefinition:
url: "http://localhost:8083/engine-rest/"

logging:
level:
Expand Down
6 changes: 6 additions & 0 deletions examples/itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@

<!-- Testing -->
<!-- add junit 4 to enable its usage until Camunda switched to JUnit 5 -->
<dependency>
<groupId>io.holunda.decision</groupId>
<artifactId>camunda-decision-model</artifactId>
<version>0.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*-
* #%L
* camunda-platform-7-rest-client-spring-boot-itest
* %%
* Copyright (C) 2019 Camunda Services GmbH
* %%
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package org.camunda.community.rest.itest

import com.tngtech.jgiven.annotation.As
import io.toolisticon.testing.jgiven.GIVEN
import io.toolisticon.testing.jgiven.THEN
import io.toolisticon.testing.jgiven.WHEN
import org.camunda.bpm.engine.DecisionService
import org.camunda.community.rest.itest.stages.CamundaRestClientITestBase
import org.camunda.community.rest.itest.stages.DecisionServiceActionStage
import org.camunda.community.rest.itest.stages.DecisionServiceAssertStage
import org.junit.Test

@As("Incident")
class DecisionServiceITest : CamundaRestClientITestBase<DecisionService, DecisionServiceActionStage, DecisionServiceAssertStage>() {

@Test
fun `should evaluate decision by id`() {
GIVEN
.no_deployment_exists()
.and()
.decision_table_is_deployed()
WHEN
.decision_is_evaluated_by_id(mutableMapOf(Pair("input1", "Rule1")))
THEN
.decision_result_is_correct(mutableMapOf(Pair("output1", "Rule1Output")))
}

@Test
fun `should evaluate decision by key`() {
GIVEN
.no_deployment_exists()
.and()
.decision_table_is_deployed()
WHEN
.decision_is_evaluated_by_key(variables = mutableMapOf(Pair("input1", "Rule1")))
THEN
.decision_result_is_correct(mutableMapOf(Pair("output1", "Rule1Output")))
}

@Test
fun `should evaluate decision table by id`() {
GIVEN
.no_deployment_exists()
.and()
.decision_table_is_deployed()
WHEN
.decision_table_is_evaluated_by_id(mutableMapOf(Pair("input1", "Rule1")))
THEN
.decision_table_result_is_correct(mutableMapOf(Pair("output1", "Rule1Output")))
}

@Test
fun `should evaluate decision table by key`() {
GIVEN
.no_deployment_exists()
.and()
.decision_table_is_deployed()
WHEN
.decision_table_is_evaluated_by_key(variables = mutableMapOf(Pair("input1", "Rule1")))
THEN
.decision_table_result_is_correct(mutableMapOf(Pair("output1", "Rule1Output")))
}

@Test
fun `should evaluate decision table by key and version`() {
GIVEN
.no_deployment_exists()
.and()
.decision_table_is_deployed()
.and()
.decision_table_is_deployed(version = "2")
WHEN
.decision_table_is_evaluated_by_key_and_version(version = 1, variables = mutableMapOf(Pair("input1", "Rule1")))
THEN
.decision_table_result_is_correct(mutableMapOf(Pair("output1", "Rule1Output")))
WHEN
.decision_table_is_evaluated_by_key_and_version(version = 2, variables = mutableMapOf(Pair("input1", "Rule1")))
THEN
.decision_table_result_is_correct(mutableMapOf(Pair("output1", "Rule1OutputV2")))
}

@Test
fun `should evaluate decision table by key with tenant`() {
GIVEN
.no_deployment_exists()
.and()
.decision_table_is_deployed(tenantId = "tenantId")
WHEN
.decision_table_is_evaluated_by_key_and_tenant(tenantId = "tenantId", variables = mutableMapOf(Pair("input1", "Rule1")))
THEN
.decision_table_result_is_correct(mutableMapOf(Pair("output1", "Rule1Output")))
}

@Test
fun `should evaluate decision table by key in drd`() {
GIVEN
.no_deployment_exists()
.and()
.drd_is_deployed()
WHEN
.decision_table_is_evaluated_by_key(decisionDefinitionKey = "table2", variables = mutableMapOf(Pair("input1", "Rule1")))
THEN
.decision_table_result_is_correct(mutableMapOf(Pair("output2", "Rule1Output2")))
}

}
Loading