Search in sources :

Example 21 with ExpressionFormLine

use of org.drools.workbench.models.datamodel.rule.ExpressionFormLine in project drools-wb by kiegroup.

the class PopupCreator method makeSingleFieldConstraintEBLeftSide.

SingleFieldConstraintEBLeftSide makeSingleFieldConstraintEBLeftSide(final String factType) {
    final SingleFieldConstraintEBLeftSide constraint = new SingleFieldConstraintEBLeftSide();
    final ExpressionFormLine expression = makeExpressionFormLine(factType);
    constraint.setConstraintValueType(SingleFieldConstraint.TYPE_UNDEFINED);
    constraint.setExpressionLeftSide(expression);
    constraint.setFactType(factType);
    return constraint;
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine)

Example 22 with ExpressionFormLine

use of org.drools.workbench.models.datamodel.rule.ExpressionFormLine in project drools-wb by kiegroup.

the class GuidedRuleEditorValidatorTest method testMissingRHSPartInFrom.

@Test
public void testMissingRHSPartInFrom() throws Exception {
    FactPattern pattern = new FactPattern("Address");
    SingleFieldConstraint constraint = new SingleFieldConstraint("street");
    pattern.addConstraint(constraint);
    FromCompositeFactPattern fromCompositeFactPattern = new FromCompositeFactPattern();
    fromCompositeFactPattern.setFactPattern(pattern);
    ExpressionFormLine expression = new ExpressionFormLine();
    fromCompositeFactPattern.setExpression(expression);
    model.lhs = new IPattern[] { fromCompositeFactPattern };
    assertFalse(validator.isValid());
    assertEquals(1, validator.getErrors().size());
    assertEquals(MISSING_RHS_FROM, validator.getErrors().get(0));
    verify(constants).WhenUsingFromTheSourceNeedsToBeSet();
}
Also used : SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) Test(org.junit.Test)

Example 23 with ExpressionFormLine

use of org.drools.workbench.models.datamodel.rule.ExpressionFormLine in project drools-wb by kiegroup.

the class GuidedRuleEditorValidatorTest method testFromAccumulateCompositePattern.

@Test
public void testFromAccumulateCompositePattern() throws Exception {
    FactPattern pattern1 = new FactPattern("Person");
    SingleFieldConstraint constraint1 = new SingleFieldConstraint("name");
    constraint1.setOperator("==");
    constraint1.setValue("Toni");
    pattern1.addConstraint(constraint1);
    FactPattern pattern2 = new FactPattern("Address");
    SingleFieldConstraint constraint2 = new SingleFieldConstraint("street");
    constraint2.setOperator("!=");
    constraint2.setValue("some street");
    pattern2.addConstraint(constraint2);
    FromAccumulateCompositeFactPattern fromAccumulateCompositeFactPattern = new FromAccumulateCompositeFactPattern();
    fromAccumulateCompositeFactPattern.setSourcePattern(pattern1);
    fromAccumulateCompositeFactPattern.setFactPattern(pattern2);
    ExpressionFormLine expression = new ExpressionFormLine();
    expression.setBinding("person.addresses");
    fromAccumulateCompositeFactPattern.setExpression(expression);
    model.lhs = new IPattern[] { fromAccumulateCompositeFactPattern };
    assertTrue(validator.isValid());
}
Also used : SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) Test(org.junit.Test)

Example 24 with ExpressionFormLine

use of org.drools.workbench.models.datamodel.rule.ExpressionFormLine in project drools-wb by kiegroup.

the class PopupCreatorTest method testMakeSingleFieldConstraintEBLeftSide.

@Test
public void testMakeSingleFieldConstraintEBLeftSide() {
    final String expectedFactType = "factType";
    final ExpressionFormLine expectedExpressionFormLine = mock(ExpressionFormLine.class);
    final int expectedConstraintValueType = SingleFieldConstraint.TYPE_UNDEFINED;
    doReturn(expectedExpressionFormLine).when(popupCreator).makeExpressionFormLine(expectedFactType);
    final SingleFieldConstraintEBLeftSide constraint = popupCreator.makeSingleFieldConstraintEBLeftSide(expectedFactType);
    assertEquals(expectedConstraintValueType, constraint.getConstraintValueType());
    assertEquals(expectedExpressionFormLine, constraint.getExpressionLeftSide());
    assertEquals(expectedFactType, constraint.getFactType());
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) Test(org.junit.Test)

Aggregations

ExpressionFormLine (org.drools.workbench.models.datamodel.rule.ExpressionFormLine)24 Test (org.junit.Test)16 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)14 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)14 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)14 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)14 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)14 ExpressionVariable (org.drools.workbench.models.datamodel.rule.ExpressionVariable)10 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)9 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)8 ExpressionText (org.drools.workbench.models.datamodel.rule.ExpressionText)7 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)7 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)6 ExpressionMethod (org.drools.workbench.models.datamodel.rule.ExpressionMethod)5 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)5 ExpressionField (org.drools.workbench.models.datamodel.rule.ExpressionField)4 ExpressionUnboundFact (org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact)3 SingleFieldConstraintEBLeftSide (org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 ExpressionCollectionIndex (org.drools.workbench.models.datamodel.rule.ExpressionCollectionIndex)2