@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());
  }
  @Test
  public void testMissingValueInFrom() throws Exception {
    FactPattern boundPattern = new FactPattern("Person");
    boundPattern.setBoundName("person");
    boundPattern.addConstraint(new SingleFieldConstraint("addresses"));

    FactPattern pattern = new FactPattern("Address");

    SingleFieldConstraint constraint = new SingleFieldConstraint("street");
    constraint.setOperator("!=");
    pattern.addConstraint(constraint);

    FromCompositeFactPattern fromCompositeFactPattern = new FromCompositeFactPattern();
    fromCompositeFactPattern.setFactPattern(pattern);
    ExpressionFormLine expression = new ExpressionFormLine();
    expression.setBinding("person.addresses");
    fromCompositeFactPattern.setExpression(expression);

    model.lhs = new IPattern[] {boundPattern, fromCompositeFactPattern};

    assertFalse(validator.isValid());
    assertEquals(1, validator.getErrors().size());
    assertEquals(MISSING_VALUE_WHEN_OPERATOR_IS_SET, validator.getErrors().get(0));

    verify(constants)
        .FactType0HasAField1ThatHasAnOperatorSetButNoValuePleaseAddAValueOrRemoveTheOperator(
            "Address", "street");
  }
  @Test
  public void testValidFromCompositeFactPattern() throws Exception {

    FactPattern factPattern = new FactPattern("SomeList");
    factPattern.setBoundName("list");

    FromCompositeFactPattern fromCompositeFactPattern = new FromCompositeFactPattern();
    fromCompositeFactPattern.setFactPattern(new FactPattern("Person"));
    ExpressionFormLine expression = new ExpressionFormLine();
    expression.appendPart(new ExpressionVariable("list", "SomeList", "SomeList"));
    fromCompositeFactPattern.setExpression(expression);
    model.lhs = new IPattern[] {fromCompositeFactPattern};

    assertTrue(validator.isValid());
  }
  @Test
  public void testWorkingFrom() throws Exception {

    FactPattern boundPattern = new FactPattern("Person");
    boundPattern.setBoundName("person");
    boundPattern.addConstraint(new SingleFieldConstraint("addresses"));

    FactPattern pattern = new FactPattern("Address");

    SingleFieldConstraint constraint = new SingleFieldConstraint("street");
    pattern.addConstraint(constraint);

    FromCompositeFactPattern fromCompositeFactPattern = new FromCompositeFactPattern();
    fromCompositeFactPattern.setFactPattern(pattern);
    ExpressionFormLine expression = new ExpressionFormLine();
    expression.setBinding("person.addresses");
    fromCompositeFactPattern.setExpression(expression);

    model.lhs = new IPattern[] {boundPattern, fromCompositeFactPattern};

    assertTrue(validator.isValid());
  }