ResourceExpression re = createResourceExpression(
"File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
re.getResourceData().add(createResourceBody(null, "a", "1", "b", "2", "c", "3"));
// swap the created LiteralNameOrReference for an AtExpression
AtExpression reRef = pf.createAtExpression();
reRef.setLeftExpr(re.getResourceExpr());
re.setResourceExpr(reRef);
// add a parameter (use of a default here is just because it requires no further value setting :)
reRef.getParameters().add(pf.createLiteralDefault());
statements.add(re);
tester.validator().checkResourceExpression(re);
tester.diagnose().assertError(IPPDiagnostics.ISSUE__RESOURCE_MULTIPLE_BODIES);
// -- bodies with titles
pp = pf.createPuppetManifest();
statements = pp.getStatements();
re = createResourceExpression(
"File", "title in error", "owner", createValue("0777"), "group", createValue("0666"), "other",
createValue("0555"));
re.getResourceData().add(createResourceBody(null, "a", "1", "b", "2", "c", "3"));
// swap the created LiteralNameOrReference for an AtExpression
reRef = pf.createAtExpression();
reRef.setLeftExpr(re.getResourceExpr());
re.setResourceExpr(reRef);
// add a parameter (use of a default here is just because it requires no further value setting :)
reRef.getParameters().add(pf.createLiteralDefault());
statements.add(re);
tester.validator().checkResourceExpression(re);
tester.diagnose().assertAll(
AssertableDiagnostics.errorCode(IPPDiagnostics.ISSUE__RESOURCE_WITH_TITLE),
AssertableDiagnostics.errorCode(IPPDiagnostics.ISSUE__RESOURCE_MULTIPLE_BODIES));
// -- states where the at expression is wrong
// -- at expression has no parameters
pp = pf.createPuppetManifest();
statements = pp.getStatements();
re = createResourceExpression(
"File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
// swap the created LiteralNameOrReference for an AtExpression
reRef = pf.createAtExpression();
reRef.setLeftExpr(re.getResourceExpr());
re.setResourceExpr(reRef);
statements.add(re);
tester.validator().checkResourceExpression(re);
tester.validator().checkAtExpression(reRef);
tester.diagnose().assertError(IPPDiagnostics.ISSUE__RESOURCE_REFERENCE_NO_PARAMETERS);
// -- at expression left is not a NameOrReference
pp = pf.createPuppetManifest();
statements = pp.getStatements();
re = createResourceExpression(
"File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
// swap the created LiteralNameOrReference for an AtExpression with faulty leftExpr
reRef = pf.createAtExpression();
reRef.setLeftExpr(pf.createLiteralDefault());
re.setResourceExpr(reRef);
// add a parameter (use of a default here is just because it requires no further value setting :)
reRef.getParameters().add(pf.createLiteralDefault());
statements.add(re);
tester.validator().checkResourceExpression(re);
tester.validator().checkAtExpression(reRef);
tester.diagnose().assertError(IPPDiagnostics.ISSUE__NOT_CLASSREF);
// -- at expression left is null
pp = pf.createPuppetManifest();
statements = pp.getStatements();
re = createResourceExpression(
"File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
// swap the created LiteralNameOrReference for an AtExpression with faulty leftExpr
reRef = pf.createAtExpression();
reRef.setLeftExpr(null);
re.setResourceExpr(reRef);
// add a parameter (use of a default here is just because it requires no further value setting :)
reRef.getParameters().add(pf.createLiteralDefault());
statements.add(re);
tester.validator().checkResourceExpression(re);
tester.validator().checkAtExpression(reRef);
tester.diagnose().assertError(IPPDiagnostics.ISSUE__RESOURCE_REFERENCE_NO_REFERENCE);