Search in sources :

Example 16 with Cheese

use of org.drools.mvel.model.Cheese in project drools by kiegroup.

the class LambdaConstraintTestUtil method createCheesePriceGreaterConstraint.

public static LambdaConstraint createCheesePriceGreaterConstraint(final int rightValue, int indexId) {
    // Typical LambdaConstraint used in drools-test-coverage. (price > xxx)
    Pattern pattern = new Pattern(0, new ClassObjectType(Cheese.class));
    Predicate1<Cheese> predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.greaterThan(_this.getPrice(), rightValue));
    AlphaIndexImpl<Cheese, Integer> index = new AlphaIndexImpl<Cheese, Integer>(Integer.class, org.drools.model.Index.ConstraintType.GREATER_THAN, indexId, _this -> _this.getPrice(), rightValue);
    return createLambdaConstraint1(Cheese.class, pattern, predicate, index);
}
Also used : Pattern(org.drools.core.rule.Pattern) DeclarationImpl(org.drools.model.impl.DeclarationImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) ClassObjectType(org.drools.core.base.ClassObjectType) Cheese(org.drools.mvel.model.Cheese)

Aggregations

Cheese (org.drools.mvel.model.Cheese)16 Test (org.junit.Test)8 ClassObjectType (org.drools.core.base.ClassObjectType)7 Pattern (org.drools.core.rule.Pattern)7 AlphaNodeFieldConstraint (org.drools.core.spi.AlphaNodeFieldConstraint)6 InternalKnowledgeBase (org.drools.kiesession.rulebase.InternalKnowledgeBase)6 StatefulKnowledgeSessionImpl (org.drools.kiesession.session.StatefulKnowledgeSessionImpl)6 AlphaNode (org.drools.core.reteoo.AlphaNode)5 DeclarationImpl (org.drools.model.impl.DeclarationImpl)5 AlphaIndexImpl (org.drools.model.index.AlphaIndexImpl)5 InternalFactHandle (org.drools.core.common.InternalFactHandle)4 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)3 PropagationContextFactory (org.drools.core.common.PropagationContextFactory)3 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)3 MockObjectSink (org.drools.core.reteoo.MockObjectSink)3 BuildContext (org.drools.core.reteoo.builder.BuildContext)3 PropagationContext (org.drools.core.spi.PropagationContext)3 MockObjectSource (org.drools.mvel.model.MockObjectSource)3 HashKey (org.drools.core.reteoo.CompositeObjectSinkAdapter.HashKey)2 Declaration (org.drools.core.rule.Declaration)2