Search in sources :

Example 6 with CEPWindow

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");
}
Also used : CEPWindow(org.drools.workbench.models.datamodel.rule.CEPWindow) Before(org.junit.Before)

Example 7 with CEPWindow

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);
}
Also used : CEPWindow(org.drools.workbench.models.datamodel.rule.CEPWindow) Test(org.junit.Test)

Example 8 with CEPWindow

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);
}
Also used : CEPWindow(org.drools.workbench.models.datamodel.rule.CEPWindow) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Example 9 with CEPWindow

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"));
}
Also used : IPattern(org.drools.workbench.models.datamodel.rule.IPattern) CEPWindow(org.drools.workbench.models.datamodel.rule.CEPWindow) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Example 10 with CEPWindow

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);
}
Also used : CEPWindow(org.drools.workbench.models.datamodel.rule.CEPWindow) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Aggregations

CEPWindow (org.drools.workbench.models.datamodel.rule.CEPWindow)11 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)7 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)7 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)7 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)7 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)7 Test (org.junit.Test)6 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)4 IFactPattern (org.drools.workbench.models.datamodel.rule.IFactPattern)3 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)2 FieldConstraint (org.drools.workbench.models.datamodel.rule.FieldConstraint)2 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)2 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)2 BehaviorDescr (org.drools.compiler.lang.descr.BehaviorDescr)1 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)1 ConnectiveConstraint (org.drools.workbench.models.datamodel.rule.ConnectiveConstraint)1 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)1 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)1 CEPWindowOperatorsDropdown (org.drools.workbench.screens.guided.rule.client.editor.CEPWindowOperatorsDropdown)1 Before (org.junit.Before)1