pibizza commented on code in PR #6200:
URL:
https://github.com/apache/incubator-kie-drools/pull/6200#discussion_r1888267530
##########
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/internal/utils/DMNRuntimeBuilderTest.java:
##########
@@ -43,4 +53,198 @@ void buildFromConfiguration() {
.fromResources(Collections.emptyList()).getOrElseThrow(RuntimeException::new);
assertThat(retrieved).isNotNull();
}
+
+ @Test
+ void fromDefaultsMultipleDecisionWithoutInputDataReference() {
+ File modelFile = FileUtils.getFile("Invalid_decisions_model.dmn");
+ assertThat(modelFile).isNotNull().exists();
+ Resource modelResource = ResourceFactory.newFileResource(modelFile);
+ DMNRuntime dmnRuntime =
DMNRuntimeBuilder.fromDefaults().buildConfiguration()
+
.fromResources(Collections.singletonList(modelResource)).getOrElseThrow(RuntimeException::new);
+ assertThat(dmnRuntime).isNotNull();
+ String nameSpace =
"https://kie.org/dmn/_BDC29BCF-B5DC-4AD7-8A5F-43DC08780F97";
+
+ final DMNModel dmnModel = dmnRuntime.getModel(
+ nameSpace,
+ "DMN_1A4BD262-7672-4887-9F25-986EE5277D16");
+ assertThat(dmnModel).isNotNull();
+ DMNContext context = DMNFactory.newContext();
+ context.set( "Person Age", 24 );
+ String errorMessage = "DMN: Error compiling FEEL expression 'Person
Age >= 18' for name 'Can Drive?' on node 'Can Drive?': syntax error near 'Age'
(DMN id: _563E78C7-EFD1-4109-9F30-B14922EF68DF, Error compiling the referenced
FEEL expression) ";
+ assertThatThrownBy(() -> dmnRuntime.evaluateAll(dmnModel, context))
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessage(errorMessage);
+ }
+
+ @Test
+ void evaluateMultipleDecisionModel() {
+ File modelFile = FileUtils.getFile("MultipleDecision.dmn");
+ assertThat(modelFile).isNotNull().exists();
+ Resource modelResource = ResourceFactory.newFileResource(modelFile);
+ DMNRuntime dmnRuntime =
DMNRuntimeBuilder.fromDefaults().buildConfiguration()
+
.fromResources(Collections.singletonList(modelResource)).getOrElseThrow(RuntimeException::new);
+ assertThat(dmnRuntime).isNotNull();
+ String nameSpace =
"https://kie.org/dmn/_CADD03FC-4ABD-46D2-B631-E7FDE384D6D7";
+
+ final DMNModel dmnModel = dmnRuntime.getModel(
+ nameSpace,
+ "DMN_54AA2CFA-2374-4FCE-8F16-B594DFF87EBE");
+ assertThat(dmnModel).isNotNull();
+ DMNContext context = DMNFactory.newContext();
+ context.set( "Person Age", 24 );
+ DMNResult dmnResult = dmnRuntime.evaluateAll(dmnModel, context);
+ assertThat(dmnResult).isNotNull();
+ }
+
+ @Test
+ void evaluateWrongDecisionWithoutInputDataReferencesByName() {
+ File modelFile = FileUtils.getFile("Invalid_decisions_model.dmn");
+ assertThat(modelFile).isNotNull().exists();
+ Resource modelResource = ResourceFactory.newFileResource(modelFile);
+ DMNRuntime dmnRuntime =
DMNRuntimeBuilder.fromDefaults().buildConfiguration()
+
.fromResources(Collections.singletonList(modelResource)).getOrElseThrow(RuntimeException::new);
+ assertThat(dmnRuntime).isNotNull();
+ String nameSpace =
"https://kie.org/dmn/_BDC29BCF-B5DC-4AD7-8A5F-43DC08780F97";
+
+ final DMNModel dmnModel = dmnRuntime.getModel(
+ nameSpace,
+ "DMN_1A4BD262-7672-4887-9F25-986EE5277D16");
+ assertThat(dmnModel).isNotNull();
+ DMNContext context = DMNFactory.newContext();
+ context.set( "Person Age", 24 );
+ String errorMessage = "DMN: Error compiling FEEL expression 'Person
Age >= 18' for name 'Can Drive?' on node 'Can Drive?': syntax error near 'Age'
(DMN id: _563E78C7-EFD1-4109-9F30-B14922EF68DF, Error compiling the referenced
FEEL expression) ";
+ assertThatThrownBy(() -> dmnRuntime.evaluateByName(dmnModel, context,
"Can Drive"))
Review Comment:
I would go for the more readable
assertThatIllegalStateExceptionIsThrownBy(.... Consider this also in the other
tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]