This is an automated email from the ASF dual-hosted git repository.

yamer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-drools.git


The following commit(s) were added to refs/heads/main by this push:
     new 89d15f69ac [Incubator kie issues#2062] DMN: Verify lenient/strict flag 
on jitexecutor (#6424)
89d15f69ac is described below

commit 89d15f69ac6db7285224de1c485420630d47052c
Author: AthiraHari77 <[email protected]>
AuthorDate: Wed Aug 20 00:10:01 2025 +0530

    [Incubator kie issues#2062] DMN: Verify lenient/strict flag on jitexecutor 
(#6424)
    
    * [incubator-kie-issue#2062] code changes for strict/lenient error handling
    
    * [incubator-kie-issue#2062] update license header
    
    * [incubator-kie-issue#2062] fix review comment
    
    ---------
    
    Co-authored-by: athira <[email protected]>
---
 .../kie/dmn/core/compiler/RuntimeModeOption.java   | 17 +++++---
 .../dmn/core/compiler/RuntimeModeOptionTest.java   | 51 ++++++++++++++++++++++
 2 files changed, 61 insertions(+), 7 deletions(-)

diff --git 
a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/RuntimeModeOption.java
 
b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/RuntimeModeOption.java
index a90ee895f2..3899ce3911 100644
--- 
a/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/RuntimeModeOption.java
+++ 
b/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/RuntimeModeOption.java
@@ -19,6 +19,8 @@
 package org.kie.dmn.core.compiler;
 
 import java.io.Serial;
+import java.util.Arrays;
+
 import org.kie.dmn.core.assembler.DMNAssemblerService;
 
 public class RuntimeModeOption implements DMNOption {
@@ -41,6 +43,13 @@ public class RuntimeModeOption implements DMNOption {
         public String getMode() {
             return mode;
         }
+
+        public static MODE getModeFromString(String modeName) {
+            return Arrays.stream(MODE.values())
+                    .filter(value -> value.mode.equals(modeName))
+                    .findFirst().orElse(MODE.LENIENT);
+        }
+
     }
 
     /**
@@ -51,13 +60,7 @@ public class RuntimeModeOption implements DMNOption {
     private final MODE runtimeMode;
 
     public RuntimeModeOption(String runtimeMode) {
-        MODE toSet = null;
-        try {
-            toSet = MODE.valueOf(runtimeMode);
-        } catch (Exception e) {
-            toSet = DEFAULT_VALUE;
-        }
-        this.runtimeMode = toSet;
+        this.runtimeMode = MODE.getModeFromString(runtimeMode);
     }
 
     public RuntimeModeOption(MODE runtimeMode) {
diff --git 
a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/RuntimeModeOptionTest.java
 
b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/RuntimeModeOptionTest.java
new file mode 100644
index 0000000000..f05ca0515e
--- /dev/null
+++ 
b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/RuntimeModeOptionTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); 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.
+ */
+package org.kie.dmn.core.compiler;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class RuntimeModeOptionTest {
+
+    @Test
+    void getRuntimeModeOption() {
+        RuntimeModeOption runtimeModeOption = new RuntimeModeOption("strict");
+        assertThat(runtimeModeOption).isNotNull();
+        
assertThat(runtimeModeOption.getRuntimeMode()).isEqualTo(RuntimeModeOption.MODE.STRICT);
+        runtimeModeOption = new RuntimeModeOption("lenient");
+        assertThat(runtimeModeOption).isNotNull();
+        
assertThat(runtimeModeOption.getRuntimeMode()).isEqualTo(RuntimeModeOption.MODE.LENIENT);
+        runtimeModeOption = new RuntimeModeOption("test");
+        assertThat(runtimeModeOption).isNotNull();
+        
assertThat(runtimeModeOption.getRuntimeMode()).isEqualTo(RuntimeModeOption.MODE.LENIENT);
+
+    }
+
+    @Test
+    void getModeFromString() {
+        String modeName = "strict";
+        
assertThat(RuntimeModeOption.MODE.getModeFromString(modeName)).isEqualTo(RuntimeModeOption.MODE.STRICT);
+        modeName = "lenient";
+        
assertThat(RuntimeModeOption.MODE.getModeFromString(modeName)).isEqualTo(RuntimeModeOption.MODE.LENIENT);
+        modeName = "test";
+        
assertThat(RuntimeModeOption.MODE.getModeFromString(modeName)).isEqualTo(RuntimeModeOption.MODE.LENIENT);
+
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to