use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class SGenJavaValidatorTest method checkParameterValueType.
/**
* @see SGenJavaValidator#checkParameterValueType(org.yakindu.sct.model.sgen.FeatureParameterValue)
*/
@Test
public void checkParameterValueType() {
EObject model = parseExpression("GeneratorModel for yakindu::java { statechart Example { feature Outlet { targetFolder = true }}}", GeneratorModel.class.getSimpleName());
AssertableDiagnostics result = tester.validate(model);
result.assertAny(new MsgPredicate("Incompatible types string and boolean."));
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class SGenJavaValidatorTest method checkDeprecatedFeatures.
/**
* @see SGenJavaValidator#checkDeprecatedFeatures(GeneratorEntry)
*/
@Test
public void checkDeprecatedFeatures() {
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().setDeprecated(true);
AssertableDiagnostics result = tester.validate(genModel);
result.assertAny(new MsgPredicate(DEPRECATED));
}
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method testMixedOptionalAndVarArgsParameters.
@Test
@Ignore("Why should anyone do that anyways")
public void testMixedOptionalAndVarArgsParameters() {
EObject model;
String rule = Expression.class.getSimpleName();
AssertableDiagnostics result;
model = parseExpression("optOp4(3)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp4(3, 4)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp4(3, 4, 5, 6)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp4(3, 4, true)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp4(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 STextJavaValidatorTest method checkAnnotations.
@Test
public void checkAnnotations() {
String scope;
StatechartSpecification model;
AssertableDiagnostics validationResult;
statechart.setName("Annotated");
scope = "@EventDriven";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertOK();
scope = "@CycleBased(200)";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertOK();
scope = "@CycleBased(200)\n" + "@EventDriven";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertErrorContains(CONTRADICTORY_ANNOTATIONS.split("%s")[0]);
scope = "@ParentFirstExecution";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertOK();
scope = "@ChildFirstExecution";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertOK();
scope = "@ParentFirstExecution\n" + "@ChildFirstExecution";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertErrorContains(CONTRADICTORY_ANNOTATIONS.split("%s")[0]);
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkReactionTriggerRegularEvent.
@Test
public void checkReactionTriggerRegularEvent() {
String scope = "interface : in event e var x : integer var y : integer operation op():integer";
EObject model = super.parseExpression("e", TransitionSpecification.class.getSimpleName(), scope);
AssertableDiagnostics validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("x", TransitionSpecification.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertError(TRIGGER_IS_NO_EVENT);
model = super.parseExpression("e, x", TransitionSpecification.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertError(TRIGGER_IS_NO_EVENT);
model = super.parseExpression("op()", TransitionSpecification.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertError(TRIGGER_IS_NO_EVENT);
model = super.parseExpression("x, y", TransitionSpecification.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertAll(errorMsg("Trigger 'x' is no event."), errorMsg("Trigger 'y' is no event."));
}
Aggregations