*/
@Test
public void test_Validate_RelationshipExpression_Ok() {
PuppetManifest pp = pf.createPuppetManifest();
// -- check file { 'file1': } -> file{'file2': } -> file{'file3' : }
RelationshipExpression rel1 = pf.createRelationshipExpression();
RelationshipExpression rel2 = pf.createRelationshipExpression();
pp.getStatements().add(rel2);
ResourceExpression r1 = createResourceExpression("file", "'file1'");
ResourceExpression r2 = createResourceExpression("file", "'file2'");
ResourceExpression r3 = createResourceExpression("file", "'file3'");
rel1.setOpName("->");
rel1.setLeftExpr(r1);
rel1.setRightExpr(r2);
rel2.setOpName("->");
rel2.setLeftExpr(rel1);
rel2.setRightExpr(r3);
tester.validator().checkRelationshipExpression(rel2);
tester.diagnose().assertOK();
// -- check the other operators
rel2.setOpName("<-");
tester.validator().checkRelationshipExpression(rel2);
tester.diagnose().assertOK();
rel2.setOpName("<~");
tester.validator().checkRelationshipExpression(rel2);
tester.diagnose().assertOK();
rel2.setOpName("~>");
tester.validator().checkRelationshipExpression(rel2);
tester.diagnose().assertOK();
// -- check the other possible left/right expressions
// - virtual
// - resource reference
// - collect expression
AtExpression at = pf.createAtExpression();
at.setLeftExpr(createNameOrReference("x"));
at.getParameters().add(createNameOrReference("a"));
r1.setResourceExpr(at); // resource reference
VirtualNameOrReference vn = pf.createVirtualNameOrReference();
vn.setValue("y");
vn.setExported(true);
r2.setResourceExpr(vn);
CollectExpression ce = pf.createCollectExpression();
ce.setClassReference(createNameOrReference("User"));
EqualityExpression predicate = pf.createEqualityExpression();
predicate.setLeftExpr(createNameOrReference("name"));
predicate.setOpName("==");
predicate.setRightExpr(createNameOrReference("Luke"));
VirtualCollectQuery q = pf.createVirtualCollectQuery();
q.setExpr(predicate);
ce.setQuery(q);
rel2.setRightExpr(ce);
tester.validator().checkRelationshipExpression(rel2);
tester.diagnose().assertOK();
}