Skip to content

Commit

Permalink
ISSUE-379: Fix error thrown when a common condition throws an excepti…
Browse files Browse the repository at this point in the history
…on in the LHS (oracle-samples#380)
  • Loading branch information
EthanEChristian authored and sparkofreason committed Feb 6, 2018
1 parent 82cd756 commit 3c9fc4e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/clojure/clara/rules/engine.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
(->> node
:children
(map get-conditions-and-rule-names)
(reduce (partial merge-with conj) {})))))
(reduce (partial merge-with into) {})))))

;; Active session during rule execution.
(def ^:dynamic *current-session* nil)
Expand Down
25 changes: 25 additions & 0 deletions src/test/clojure/clara/test_rules.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2371,6 +2371,31 @@
(fire-rules)
(query temperature-query1)))))

;; See https://github.com/cerner/clara-rules/issues/379 for more info
(deftest test-single-condition-multiple-rule-constraint-exception
(let [rule-one (dsl/parse-rule [[WindSpeed
(= ?location location)]
[Temperature
(> temperature 0)]]
(println ?location))
rule-two (dsl/parse-rule [[Cold
(> 21 temperature)]
[Temperature
(> temperature 0)]]
(println "ok"))
temperature-rule1 (assoc rule-one :name "rule-1")
temperature-rule2 (assoc rule-two :name "rule-2")
temperature-fact (->Temperature nil "MCI")]

(assert-ex-data {:bindings nil
:fact temperature-fact
:conditions-and-rules
{[clara.rules.testfacts.Temperature '(> temperature 0)]
(sorted-set [:production "rule-1"] [:production "rule-2"])}}
(-> (mk-session [temperature-rule1 temperature-rule2] :cache false)
(insert temperature-fact)
(fire-rules)))))

(deftest test-single-condition-rules-constraint-exception
(let [rule-template (dsl/parse-rule [[Temperature
(= ?location location)
Expand Down

0 comments on commit 3c9fc4e

Please sign in to comment.