assertEquals(expected, drl);
}
@Test
public void testExpandQuery() throws Exception {
DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
String dsl = "[when]There is a person=Person()\n" +
"[when]- {field:\\w*} {operator} {value:\\d*}={field} {operator} {value}\n" +
"[when]is greater than=>";
String source = "query \"isMature\"\n" +
"There is a person\n" +
"- age is greater than 18\n" +
"end\n";
String expected = "query \"isMature\"\n" +
"Person(age > 18)\n" +
"end\n";
file.parseAndLoad(new StringReader(dsl));
assertEquals(0,
file.getErrors().size());
DefaultExpander ex = new DefaultExpander();
ex.addDSLMapping(file.getMapping());
String drl = ex.expand(source);
assertFalse(ex.hasErrors());
assertEquals(expected, drl);