From 5bcb5133b8567e5bd8d9bebcae509fd59b029cac Mon Sep 17 00:00:00 2001 From: Toshiya Kobayashi Date: Fri, 17 Nov 2023 17:15:46 +0900 Subject: [PATCH] [RHDM-2006] Please backport issue DROOLS-7014 to Red Hat Decision Manager libraries (#3001) - Added test case for kie-karaf-itests --- .../java/org/kie/karaf/itest/blueprint/domain/Order.java | 5 +++++ .../test/resources/drl_blueprint_import_test/rules.drl | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kie-osgi/kie-karaf-itests-domain-model/src/main/java/org/kie/karaf/itest/blueprint/domain/Order.java b/kie-osgi/kie-karaf-itests-domain-model/src/main/java/org/kie/karaf/itest/blueprint/domain/Order.java index 5a42660a78..dac21df234 100644 --- a/kie-osgi/kie-karaf-itests-domain-model/src/main/java/org/kie/karaf/itest/blueprint/domain/Order.java +++ b/kie-osgi/kie-karaf-itests-domain-model/src/main/java/org/kie/karaf/itest/blueprint/domain/Order.java @@ -23,6 +23,11 @@ public void disapprove() { this.approved = false; } + // This method duplicates with approve() and disapprove(). But added to clarify bitmask issue DROOLS-7014. + public void setApproved(Boolean approved) { + this.approved = approved; + } + public Customer getCustomer() { return this.customer; } diff --git a/kie-osgi/kie-karaf-itests/src/test/resources/drl_blueprint_import_test/rules.drl b/kie-osgi/kie-karaf-itests/src/test/resources/drl_blueprint_import_test/rules.drl index dd613164d5..0a1a522edf 100644 --- a/kie-osgi/kie-karaf-itests/src/test/resources/drl_blueprint_import_test/rules.drl +++ b/kie-osgi/kie-karaf-itests/src/test/resources/drl_blueprint_import_test/rules.drl @@ -8,19 +8,22 @@ rule "approve non-alcoholic drink" when order: Order(isApproved() == null, drink.containsAlcohol == false) then - order.approve(); + order.setApproved(true); + update(order); end rule "approve alcoholic drink" when order: Order(isApproved() == null, drink.containsAlcohol, customer.ageInYears >= 18) then - order.approve(); + order.setApproved(true); + update(order); end rule "disapprove alcoholic drink for too young customer" when order: Order(isApproved() == null, drink.containsAlcohol, customer.ageInYears < 18) then - order.disapprove(); + order.setApproved(false); + update(order); end