use of org.drools.mvel.accessors.ClassFieldAccessorStore in project drools by kiegroup.
the class FloatClassFieldExtractorTest method setUp.
@Before
public void setUp() throws Exception {
ClassFieldAccessorStore store = new ClassFieldAccessorStore();
store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
store.setEagerWire(true);
this.reader = store.getReader(TestBean.class, "floatAttr");
}
use of org.drools.mvel.accessors.ClassFieldAccessorStore in project drools by kiegroup.
the class LongClassFieldExtractorTest method setUp.
@Before
public void setUp() throws Exception {
ClassFieldAccessorStore store = new ClassFieldAccessorStore();
store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
store.setEagerWire(true);
extractor = store.getReader(TestBean.class, "longAttr");
}
use of org.drools.mvel.accessors.ClassFieldAccessorStore in project drools by kiegroup.
the class ObjectClassFieldExtractorTest method testIsNullValue.
@Test
public void testIsNullValue() {
assertFalse(this.reader.isNullValue(null, this.bean));
ClassFieldAccessorStore store = new ClassFieldAccessorStore();
store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
store.setEagerWire(true);
InternalReadAccessor nullExtractor = store.getReader(TestBean.class, "nullAttr");
assertTrue(nullExtractor.isNullValue(null, this.bean));
}
use of org.drools.mvel.accessors.ClassFieldAccessorStore in project drools by kiegroup.
the class ShortClassFieldExtractorTest method setUp.
@Before
public void setUp() throws Exception {
ClassFieldAccessorStore store = new ClassFieldAccessorStore();
store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
store.setEagerWire(true);
this.reader = store.getReader(TestBean.class, "shortAttr");
}
use of org.drools.mvel.accessors.ClassFieldAccessorStore in project drools by kiegroup.
the class BaseBetaConstraintsTest method getCheeseTypeConstraint.
protected BetaNodeFieldConstraint getCheeseTypeConstraint(final String identifier, Operator operator) {
if (useLambdaConstraint) {
Pattern pattern = new Pattern(0, new ClassObjectType(Cheese.class));
Predicate1<Cheese> predicate;
if (operator == Operator.BuiltInOperator.EQUAL.getOperator()) {
predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.areNullSafeEquals(_this.getType(), identifier));
} else if (operator == Operator.BuiltInOperator.NOT_EQUAL.getOperator()) {
predicate = new Predicate1.Impl<Cheese>(_this -> !EvaluationUtil.areNullSafeEquals(_this.getType(), identifier));
} else if (operator == Operator.BuiltInOperator.GREATER.getOperator()) {
predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.greaterThan(_this.getType(), identifier));
} else if (operator == Operator.BuiltInOperator.GREATER_OR_EQUAL.getOperator()) {
predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.greaterOrEqual(_this.getType(), identifier));
} else if (operator == Operator.BuiltInOperator.LESS.getOperator()) {
predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.lessThan(_this.getType(), identifier));
} else if (operator == Operator.BuiltInOperator.GREATER_OR_EQUAL.getOperator()) {
predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.lessOrEqual(_this.getType(), identifier));
} else {
throw new RuntimeException(operator + " is not supported");
}
return LambdaConstraintTestUtil.createLambdaConstraint1(Cheese.class, pattern, predicate, null);
} else {
ClassFieldAccessorStore store = new ClassFieldAccessorStore();
store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
store.setEagerWire(true);
InternalReadAccessor extractor = store.getReader(Cheese.class, "type");
Declaration declaration = new Declaration(identifier, extractor, new Pattern(0, new ClassObjectType(Cheese.class)));
String expression = "type " + operator.getOperatorString() + " " + identifier;
return new MVELConstraintTestUtil(expression, operator.getOperatorString(), declaration, extractor);
}
}
Aggregations