Search in sources :

Example 16 with AssertableDiagnostics

use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.

the class STextJavaValidatorTest method checkReadOnlyValueDefinitionExpression.

@Test
public void checkReadOnlyValueDefinitionExpression() {
    String decl = "internal: var readonly 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, "readonly"));
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) EObject(org.eclipse.emf.ecore.EObject) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Test(org.junit.Test)

Example 17 with AssertableDiagnostics

use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.

the class STextJavaValidatorTest method checkOperationArguments_FeatureCall.

/**
 * @see STextJavaValidator#checkOperationArguments_FeatureCall(org.yakindu.sct.model.stext.stext.FeatureCall)
 */
@Test
public void checkOperationArguments_FeatureCall() {
    String scope = "interface if : operation myOperation(param1 : integer, param2: boolean";
    EObject model = super.parseExpression("if.myOperation(5,true)", Expression.class.getSimpleName(), scope);
    AssertableDiagnostics validationResult = tester.validate(model);
    validationResult.assertOK();
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) Expression(org.yakindu.base.expressions.expressions.Expression) EObject(org.eclipse.emf.ecore.EObject) Test(org.junit.Test)

Example 18 with AssertableDiagnostics

use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.

the class STextJavaValidatorTest method checkGuard.

/**
 * @see STextJavaValidator#checkGuardHasBooleanExpression(org.yakindu.sct.model.stext.stext.ReactionTrigger)
 */
@Test
public void checkGuard() {
    EObject expression = super.parseExpression("[3 * 3]", ReactionTrigger.class.getSimpleName());
    AssertableDiagnostics validationResult = tester.validate(expression);
    validationResult.assertErrorContains(STextJavaValidator.GUARD_EXPRESSION);
    String scope = "internal: var myInt : integer var myBool : boolean = true";
    expression = super.parseExpression("[myInt <= 5 || !myBool ]", ReactionTrigger.class.getSimpleName(), scope);
    validationResult = tester.validate(expression);
    validationResult.assertOK();
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) EObject(org.eclipse.emf.ecore.EObject) Test(org.junit.Test)

Example 19 with AssertableDiagnostics

use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.

the class STextJavaValidatorTest method checkFeatureCall.

/**
 * @see STextJavaValidator#checkFeatureCall(org.yakindu.sct.model.stext.stext.FeatureCall)
 * @see STextJavaValidator#checkFeatureCall(TypedElementReferenceExpression)
 */
@Test
public void checkFeatureCall() {
    String scope = "interface if : in event a : integer";
    EObject model = super.parseExpression("if.a / raise if.a:1", TransitionSpecification.class.getSimpleName(), scope);
    AssertableDiagnostics validationResult = tester.validate(model);
    validationResult.assertOK();
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) EObject(org.eclipse.emf.ecore.EObject) TransitionSpecification(org.yakindu.sct.model.stext.stext.TransitionSpecification) Test(org.junit.Test)

Example 20 with AssertableDiagnostics

use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.

the class STextJavaValidatorTest method checkInterfaceScope.

/**
 * @see STextJavaValidator#checkInterfaceScope(Statechart)
 */
@Test
public void checkInterfaceScope() {
    EObject model = super.parseExpression("interface: in event event1 interface: in event event2", StatechartSpecification.class.getSimpleName());
    AssertableDiagnostics result = tester.validate(model);
    result.assertDiagnosticsCount(2);
    result.assertAll(errorCode(ONLY_ONE_INTERFACE), errorCode(ONLY_ONE_INTERFACE));
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) EObject(org.eclipse.emf.ecore.EObject) StatechartSpecification(org.yakindu.sct.model.stext.stext.StatechartSpecification) Test(org.junit.Test)

Aggregations

AssertableDiagnostics (org.eclipse.xtext.junit4.validation.AssertableDiagnostics)42 Test (org.junit.Test)42 EObject (org.eclipse.emf.ecore.EObject)38 AbstractSGenTest (org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest)11 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)11 InternalScope (org.yakindu.sct.model.stext.stext.InternalScope)7 Expression (org.yakindu.base.expressions.expressions.Expression)6 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)3 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)3 StatechartSpecification (org.yakindu.sct.model.stext.stext.StatechartSpecification)3 TransitionSpecification (org.yakindu.sct.model.stext.stext.TransitionSpecification)3 Scope (org.yakindu.sct.model.sgraph.Scope)2 ImportScope (org.yakindu.sct.model.stext.stext.ImportScope)2 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)2 Diagnostic (org.eclipse.emf.common.util.Diagnostic)1 Ignore (org.junit.Ignore)1