Skip to content

Commit

Permalink
DROOLS-5690 : It should be possible to add free form insert with Free…
Browse files Browse the repository at this point in the history
… Form Field
  • Loading branch information
Rikkola committed Oct 2, 2020
1 parent 9e335b0 commit 0af429e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2993,6 +2993,10 @@ private void parseRhs(final RuleModel m,
m,
isJavaDialect);
}
} else {
FreeFormLine ffl = new FreeFormLine();
ffl.setText(line);
m.addRhsItem(ffl);
}
} else if (line.startsWith("update")) {
String variable = unwrapParenthesis(line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,34 @@ public void testEval() {
assertEquals("eval( true )",
((FreeFormLine) m.lhs[0]).getText());
}
@Test
public void testInsertFreeFormLine() {
String drl = "package com.myspace;\n" +
"\n" +
"import java.util.logging.Logger;\n" +
"\n" +
"rule \"initialize\"\n" +
"\tdialect \"mvel\"\n" +
"\twhen\n" +
"\tthen\n" +
"\t\tinsert(Logger log = Logger.getLogger(\"com.somepkg\"));\n" +
"\t\tinsert(new String(\"hello\"));\n" +
"end\n";

RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl,
Collections.emptyList(),
dmo);

assertNotNull(m);
assertEquals(2,
m.rhs.length);
assertTrue(m.rhs[0] instanceof FreeFormLine);
assertEquals("insert(Logger log = Logger.getLogger(\"com.somepkg\"));",
((FreeFormLine) m.rhs[0]).getText());
assertTrue(m.rhs[1] instanceof FreeFormLine);
assertEquals("insert(new String(\"hello\"));",
((FreeFormLine) m.rhs[1]).getText());
}

@Test
public void testEval2() {
Expand Down

0 comments on commit 0af429e

Please sign in to comment.