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;
}
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();
}
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());
}
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());
}
Aggregations