GithubHelp home page GithubHelp logo

Comments (6)

Clayton7510 avatar Clayton7510 commented on May 22, 2024 1

I updated the tests and just pushed 0.5.1 to Maven with this bug fix.

from rulebook.

Clayton7510 avatar Clayton7510 commented on May 22, 2024

@Gersee I haven't forgot about you. I just have to prep for a meeting with a client tomorrow.
So, I will check this out and respond later tomorrow.

from rulebook.

Clayton7510 avatar Clayton7510 commented on May 22, 2024

@Gersee you are correct. I checked out your example and there is a situation where the @when condition is not evaluated. I corrected this bug and updated it in the 0.5.1-SNAPSHOT and on the develop branch. I will be doing a patch release to push 0.5.1 to Maven Central this weekend.

from rulebook.

agnibha92 avatar agnibha92 commented on May 22, 2024

Still Facing The Same issue in 0.11. I am currently using POJO Based Rules and the runner skipped the method marked with @when annotation and Directly Called @then

from rulebook.

agnibha92 avatar agnibha92 commented on May 22, 2024
_rule.setCondition(Arrays.stream(_pojoRule.getClass().getMethods())
            .filter(method -> method.getReturnType() == boolean.class || method.getReturnType() == Boolean.class)
            .filter(method -> 
Arrays.stream(method.getDeclaredAnnotations()).anyMatch(When.class::isInstance))
            .findFirst()
            .<Predicate>map(method -> object -> {
              try {
                return (Boolean) method.invoke(_pojoRule);
              } catch (InvocationTargetException | IllegalAccessException ex) {
                if (_actionType == RuleChainActionType.ERROR_ON_FAILURE) {
                  throw new RuleException(ex.getCause() == null ? ex : ex.getCause());
                }
                LOGGER.error(
                    "Unable to validate condition due to an exception. It will be evaluated as false", ex);
                return false;
              }
            })
            //If the condition still can't be determined, then just hand back one that returns true
            .orElse(o -> true));

This code is returning no methods.

from rulebook.

agnibha92 avatar agnibha92 commented on May 22, 2024

I Used The When Method as a private method, because of that the problem arrived as getMethods() returns only public method. Is there any reason why getDeclaredMethods() was not used?

from rulebook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.