Search in sources :

Example 1 with WorkingMemoryImpl

use of org.mvel2.tests.core.res.WorkingMemoryImpl in project mvel by mikebrock.

the class CoreConfidenceTests method testsequentialAccessorsThenMethodCall.

public void testsequentialAccessorsThenMethodCall() {
    String expr = "System.out.println(drools.workingMemory); " + "drools.workingMemory.ruleBase.removeRule(\"org.drools.examples\", \"some rule\"); ";
    ExpressionCompiler compiler = new ExpressionCompiler(expr);
    ParserContext context = new ParserContext();
    context.setStrictTypeEnforcement(true);
    context.addInput("drools", KnowledgeHelper.class);
    RuleBase ruleBase = new RuleBaseImpl();
    WorkingMemory wm = new WorkingMemoryImpl(ruleBase);
    KnowledgeHelper drools = new DefaultKnowledgeHelper(wm);
    Map vars = new HashMap();
    vars.put("drools", drools);
    executeExpression(compiler.compile(context), vars);
}
Also used : ExpressionCompiler(org.mvel2.compiler.ExpressionCompiler)

Example 2 with WorkingMemoryImpl

use of org.mvel2.tests.core.res.WorkingMemoryImpl in project mvel by mvel.

the class CoreConfidenceTests method testsequentialAccessorsThenMethodCall.

public void testsequentialAccessorsThenMethodCall() {
    String expr = "System.out.println(drools.workingMemory); " + "drools.workingMemory.ruleBase.removeRule(\"org.drools.examples\", \"some rule\"); ";
    ParserContext context = new ParserContext();
    context.setStrictTypeEnforcement(true);
    context.addInput("drools", KnowledgeHelper.class);
    RuleBase ruleBase = new RuleBaseImpl();
    WorkingMemory wm = new WorkingMemoryImpl(ruleBase);
    KnowledgeHelper drools = new DefaultKnowledgeHelper(wm);
    Map vars = new HashMap();
    vars.put("drools", drools);
    ExpressionCompiler compiler = new ExpressionCompiler(expr, context);
    executeExpression(compiler.compile(), vars);
}
Also used : WorkingMemoryImpl(org.mvel2.tests.core.res.WorkingMemoryImpl) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) WorkingMemory(org.mvel2.tests.core.res.WorkingMemory) DefaultKnowledgeHelper(org.mvel2.tests.core.res.DefaultKnowledgeHelper) DefaultKnowledgeHelper(org.mvel2.tests.core.res.DefaultKnowledgeHelper) KnowledgeHelper(org.mvel2.tests.core.res.KnowledgeHelper) ExpressionCompiler(org.mvel2.compiler.ExpressionCompiler) ParserContext(org.mvel2.ParserContext) RuleBaseImpl(org.mvel2.tests.core.res.RuleBaseImpl) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) RuleBase(org.mvel2.tests.core.res.RuleBase)

Aggregations

ExpressionCompiler (org.mvel2.compiler.ExpressionCompiler)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ParserContext (org.mvel2.ParserContext)1 DefaultKnowledgeHelper (org.mvel2.tests.core.res.DefaultKnowledgeHelper)1 KnowledgeHelper (org.mvel2.tests.core.res.KnowledgeHelper)1 RuleBase (org.mvel2.tests.core.res.RuleBase)1 RuleBaseImpl (org.mvel2.tests.core.res.RuleBaseImpl)1 WorkingMemory (org.mvel2.tests.core.res.WorkingMemory)1 WorkingMemoryImpl (org.mvel2.tests.core.res.WorkingMemoryImpl)1