use of org.drools.workbench.models.datamodel.rule.CEPWindow in project drools by kiegroup.
the class Pattern52Test method setup.
@Before
public void setup() {
column1 = new Pattern52();
column1.setFactType("Fact");
column1.setBoundName("$var");
column1.setNegated(false);
column1.setWindow(new CEPWindow());
column1.setEntryPointName("entryPoint");
column2 = new Pattern52();
column2.setFactType("Fact");
column2.setBoundName("$var");
column2.setNegated(false);
column2.setWindow(new CEPWindow());
column2.setEntryPointName("entryPoint");
}
use of org.drools.workbench.models.datamodel.rule.CEPWindow in project drools by kiegroup.
the class Pattern52Test method testDiffWindow.
@Test
public void testDiffWindow() {
CEPWindow window1 = new CEPWindow();
window1.setOperator("dummyOp1");
column1.setWindow(window1);
CEPWindow window2 = new CEPWindow();
window2.setOperator("dummyOp2");
column2.setWindow(window2);
checkSingleDiff(FIELD_WINDOW, window1, window2, column1, column2);
}
use of org.drools.workbench.models.datamodel.rule.CEPWindow in project drools by kiegroup.
the class RuleModelDRLPersistenceUnmarshallingTest method testReciprocal_SingleFieldConstraintCEPOperatorTimeWindow.
@Test
public void testReciprocal_SingleFieldConstraintCEPOperatorTimeWindow() {
// This is the inverse of "SingleFieldConstraintCEPOperatorTimeWindow"
String drl = "rule \"rule1\"\n" + "dialect \"mvel\"\n" + "when\n" + "Event() over window:time (1d)\n" + "then\n" + "end";
RuleModel m = new RuleModel();
m.name = "rule1";
FactPattern fp1 = new FactPattern();
fp1.setFactType("Event");
CEPWindow window = new CEPWindow();
window.setOperator("over window:time");
window.getParameters().put("1", "1d");
window.getParameters().put("org.drools.workbench.models.commons.backend.rule.operatorParameterGenerator", "org.drools.workbench.models.commons.backend.rule.CEPWindowOperatorParameterDRLBuilder");
fp1.setWindow(window);
m.addLhsItem(fp1);
String actualDrl = RuleModelDRLPersistenceImpl.getInstance().marshal(m);
assertEqualsIgnoreWhitespace(drl, actualDrl);
}
use of org.drools.workbench.models.datamodel.rule.CEPWindow in project drools by kiegroup.
the class RuleModelDRLPersistenceUnmarshallingTest method testSingleFieldConstraintCEPOperatorTimeLength.
@Test
public void testSingleFieldConstraintCEPOperatorTimeLength() {
String drl = "rule \"rule1\"\n" + "when\n" + "Event() over window:length (10)\n" + "then\n" + "end";
RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl, Collections.emptyList(), dmo);
assertNotNull(m);
assertEquals("rule1", m.name);
assertEquals(1, m.lhs.length);
IPattern p1 = m.lhs[0];
assertTrue(p1 instanceof FactPattern);
FactPattern fp1 = (FactPattern) p1;
assertEquals("Event", fp1.getFactType());
assertNull(fp1.getBoundName());
assertEquals(0, fp1.getNumberOfConstraints());
assertNotNull(fp1.getWindow());
CEPWindow window = fp1.getWindow();
assertEquals("over window:length", window.getOperator());
assertEquals(2, window.getParameters().size());
assertEquals("10", window.getParameter("1"));
assertEquals("org.drools.workbench.models.commons.backend.rule.CEPWindowOperatorParameterDRLBuilder", window.getParameter("org.drools.workbench.models.commons.backend.rule.operatorParameterGenerator"));
}
use of org.drools.workbench.models.datamodel.rule.CEPWindow in project drools by kiegroup.
the class RuleModelDRLPersistenceUnmarshallingTest method testReciprocal_SingleFieldConstraintCEPOperatorTimeLength.
@Test
public void testReciprocal_SingleFieldConstraintCEPOperatorTimeLength() {
// This is the inverse of "SingleFieldConstraintCEPOperatorTimeLength"
String drl = "rule \"rule1\"\n" + "dialect \"mvel\"\n" + "when\n" + "Event() over window:length (10)\n" + "then\n" + "end";
RuleModel m = new RuleModel();
m.name = "rule1";
FactPattern fp1 = new FactPattern();
fp1.setFactType("Event");
CEPWindow window = new CEPWindow();
window.setOperator("over window:length");
window.getParameters().put("1", "10");
window.getParameters().put("org.drools.workbench.models.commons.backend.rule.operatorParameterGenerator", "org.drools.workbench.models.commons.backend.rule.CEPWindowOperatorParameterDRLBuilder");
fp1.setWindow(window);
m.addLhsItem(fp1);
String actualDrl = RuleModelDRLPersistenceImpl.getInstance().marshal(m);
assertEqualsIgnoreWhitespace(drl, actualDrl);
}
Aggregations