use of org.drools.compiler.lang.MVELDumper.MVELDumperContext in project drools by kiegroup.
the class MVELDumperTest method testDumpBindingsComplexOp.
@Test
public void testDumpBindingsComplexOp() throws Exception {
String input = "$x : age in (10, 20, $someVal)";
String expected = "( age == 10 || age == 20 || age == $someVal )";
ConstraintConnectiveDescr descr = parse(input);
MVELDumperContext ctx = new MVELDumperContext();
String result = dumper.dump(descr, ctx);
assertEquals(expected, result);
assertEquals(1, ctx.getBindings().size());
BindingDescr bind = ctx.getBindings().get(0);
assertEquals("$x", bind.getVariable());
assertEquals("age", bind.getExpression());
}
use of org.drools.compiler.lang.MVELDumper.MVELDumperContext in project drools by kiegroup.
the class MVELDumperTest method testDumpBindingsComplexOp2.
@Test
public void testDumpBindingsComplexOp2() throws Exception {
String input = "$x : age not in (10, 20, $someVal)";
String expected = "age != 10 && age != 20 && age != $someVal";
ConstraintConnectiveDescr descr = parse(input);
MVELDumperContext ctx = new MVELDumperContext();
String result = dumper.dump(descr, ctx);
assertEquals(expected, result);
assertEquals(1, ctx.getBindings().size());
BindingDescr bind = ctx.getBindings().get(0);
assertEquals("$x", bind.getVariable());
assertEquals("age", bind.getExpression());
}
use of org.drools.compiler.lang.MVELDumper.MVELDumperContext in project drools by kiegroup.
the class MVELDumperTest method testDumpBindingsWithRestriction.
@Test
public void testDumpBindingsWithRestriction() throws Exception {
String input = "$x : age > 10 && < 20 || > 30";
String expected = "( age > 10 && age < 20 || age > 30 )";
ConstraintConnectiveDescr descr = parse(input);
MVELDumperContext ctx = new MVELDumperContext();
String result = dumper.dump(descr, ctx);
assertEquals(expected, result);
assertEquals(1, ctx.getBindings().size());
BindingDescr bind = ctx.getBindings().get(0);
assertEquals("$x", bind.getVariable());
assertEquals("age", bind.getExpression());
}
use of org.drools.compiler.lang.MVELDumper.MVELDumperContext in project drools by kiegroup.
the class MVELDumperTest method testDumpBindings2.
@Test
public void testDumpBindings2() throws Exception {
String input = "( $a : a > $b : b[10].prop || 10 != 20 ) && $x : someMethod(10) == 20";
String expected = "( a > b[10].prop || 10 != 20 ) && someMethod(10) == 20";
ConstraintConnectiveDescr descr = parse(input);
MVELDumperContext ctx = new MVELDumperContext();
String result = dumper.dump(descr, ctx);
assertEquals(expected, result);
assertEquals(3, ctx.getBindings().size());
BindingDescr bind = ctx.getBindings().get(0);
assertEquals("$a", bind.getVariable());
assertEquals("a", bind.getExpression());
bind = ctx.getBindings().get(1);
assertEquals("$b", bind.getVariable());
assertEquals("b[10].prop", bind.getExpression());
bind = ctx.getBindings().get(2);
assertEquals("$x", bind.getVariable());
assertEquals("someMethod(10)", bind.getExpression());
}
use of org.drools.compiler.lang.MVELDumper.MVELDumperContext in project drools by kiegroup.
the class MVELDumperTest method testDumpBindings.
@Test
public void testDumpBindings() throws Exception {
String input = "$x : property > value";
String expected = "property > value";
ConstraintConnectiveDescr descr = parse(input);
MVELDumperContext ctx = new MVELDumperContext();
String result = dumper.dump(descr, ctx);
assertEquals(expected, result);
assertEquals(1, ctx.getBindings().size());
BindingDescr bind = ctx.getBindings().get(0);
assertEquals("$x", bind.getVariable());
assertEquals("property", bind.getExpression());
}
Aggregations