Skip to content

Commit

Permalink
DROOLS-2263: Cover marshalling of enums with comma inside
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Marko committed Jan 30, 2018
1 parent 7c8132b commit 1a6e64a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,33 @@ public void testInOperatorString() {
m);
}

@Test
public void testInOperatorStringCommaInside() {

final RuleModel model = new RuleModel();
model.name = "in";

final FactPattern pattern = new FactPattern("Person");
final SingleFieldConstraint constraint = new SingleFieldConstraint();
constraint.setFieldType(DataType.TYPE_STRING);
constraint.setFieldName("field1");
constraint.setOperator("in");
constraint.setValue("value1, \"value2, value3\"");
constraint.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
pattern.addConstraint(constraint);

model.addLhsItem(pattern);

final String expected = "rule \"in\" \n"
+ "dialect \"mvel\" \n"
+ "when \n"
+ " Person(field1 in ( \"value1\", \"value2, value3\" ) ) \n"
+ " then \n"
+ "end";

checkMarshalling(expected, model);
}

@Test
public void testInOperatorNumber() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2789,15 +2789,15 @@ public void testLHSInOperator() {
p1.getChildColumns().add(cc2);

dt.setData(DataUtilities.makeDataLists(new Object[][]{
new Object[]{1l, "desc", "Pupa, Brains", "55, 66"},
new Object[]{1l, "desc", "Pupa, Brains, \"John, Snow\"", "55, 66"},
new Object[]{2l, "desc", "", ""}
}));

GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);

int index = -1;
index = drl.indexOf("Smurf( name in ( \"Pupa\", \"Brains\" ) , age in ( 55, 66 ) )");
index = drl.indexOf("Smurf( name in ( \"Pupa\", \"Brains\", \"John, Snow\" ) , age in ( 55, 66 ) )");
assertTrue(index > -1);

index = drl.indexOf("Smurf( )",
Expand Down

0 comments on commit 1a6e64a

Please sign in to comment.