use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkExternalValueDefinitionExpression.
@Test
public void checkExternalValueDefinitionExpression() {
String decl = "internal: var external v1:integer";
EObject model = super.parseExpression(decl, InternalScope.class.getSimpleName());
AssertableDiagnostics result = tester.validate(model);
result.assertDiagnosticsCount(1);
result.assertWarningContains(String.format(STextJavaValidator.DECLARATION_DEPRECATED, "external"));
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkOperationNamedParameters.
@Test
public void checkOperationNamedParameters() {
String scope = "internal: operation myOperation(param1 : integer, param2 : boolean)";
EObject model = super.parseExpression(scope, InternalScope.class.getSimpleName());
AssertableDiagnostics validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("myOperation(5, true)", Expression.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("myOperation(5, param2 = true)", Expression.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("myOperation(param1 = 5, true)", Expression.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("myOperation(param1 = 5, param2 = true)", Expression.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("myOperation(param2 = true, param1 = 5)", Expression.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("myOperation(param2 = true)", Expression.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertError(ERROR_WRONG_NUMBER_OF_ARGUMENTS_CODE);
model = super.parseExpression("myOperation(param1 = 5)", Expression.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertError(ERROR_WRONG_NUMBER_OF_ARGUMENTS_CODE);
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkImportExists.
@Test
public void checkImportExists() {
Scope context = (Scope) parseExpression("import: \"does.not.exist\"", ImportScope.class.getSimpleName());
AssertableDiagnostics validationResult = tester.validate(context);
validationResult.assertErrorContains(String.format(STextValidationMessages.IMPORT_NOT_RESOLVED_MSG, "does.not.exist"));
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method testMixedOptionalParameters.
@Test
public void testMixedOptionalParameters() {
EObject model;
String rule = Expression.class.getSimpleName();
AssertableDiagnostics result;
model = parseExpression("optOp3(3)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp3(3, 4)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp3(3, 4, true)", rule);
result = tester.validate(model);
result.assertError(ERROR_WRONG_NUMBER_OF_ARGUMENTS_CODE);
model = parseExpression("optOp3()", rule);
result = tester.validate(model);
result.assertError(ERROR_WRONG_NUMBER_OF_ARGUMENTS_CODE);
model = parseExpression("optOp3(3, true)", rule);
result = tester.validate(model);
result.assertError(ITypeSystemInferrer.NOT_COMPATIBLE_CODE);
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class SGenJavaValidatorTest method checkDeprecatedParameters.
/**
* @see SGenJavaValidator#checkDeprecatedParameters(GeneratorEntry)
*/
@Test
public void checkDeprecatedParameters() {
EObject model = parseExpression("GeneratorModel for yakindu::java { statechart Example { feature Outlet {targetFolder = \"src-gen\" targetProject = \"TestProject\" }}}", GeneratorModel.class.getSimpleName());
if (!(model instanceof GeneratorModel)) {
fail("Model is of the wrong type");
} else {
GeneratorModel genModel = (GeneratorModel) model;
genModel.getEntries().get(0).getFeatures().get(0).getType().getParameters().get(0).setDeprecated(true);
AssertableDiagnostics result = tester.validate(genModel);
result.assertAny(new MsgPredicate(DEPRECATED));
}
}
Aggregations