Java Code Examples for org.eclipse.xtext.junit4.validation.AssertableDiagnostics#assertAny()

The following examples show how to use org.eclipse.xtext.junit4.validation.AssertableDiagnostics#assertAny() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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;
		FeatureParameter featureParameter = genModel.getEntries().get(0).getFeatures().get(0).getType().getParameters().get(0);
		featureParameter.setDeprecated(true);
		AssertableDiagnostics result = tester.validate(genModel);
		result.assertAny(new MsgPredicate(String.format(DEPRECATED, featureParameter.getName())));
	}
}
 
Example 2
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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;
		FeatureType type = genModel.getEntries().get(0).getFeatures().get(0).getType();
		type.setDeprecated(true);
		AssertableDiagnostics result = tester.validate(genModel);
		result.assertAny(new MsgPredicate(String.format(DEPRECATED, type.getName())));
	}
}
 
Example 3
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see SGenJavaValidator#checkGeneratorExists(GeneratorModel)
 */
@Test
public void checkGeneratorExists() {
	EObject model = parseExpression("GeneratorModel for yakindu::unknown {}", GeneratorModel.class.getSimpleName());
	AssertableDiagnostics result = tester.validate(model);
	result.assertAny(new MsgPredicate(UNKOWN_GENERATOR));
}
 
Example 4
Source File: XsemanticsValidatorTests.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected void assertDuplicateErrors(AssertableDiagnostics validate,
		String elementClassName, String duplicateName,
		String... msgFragments) {
	//System.out.println(diagnosticsToString(validate));
	String messageFragment = "Duplicate " + elementClassName + " '"
			+ duplicateName + "'";
	validate.assertAll(AssertableDiagnostics.errorMsg(messageFragment),
			AssertableDiagnostics.errorMsg(messageFragment));
	for (String msgFragment : msgFragments) {
		validate.assertAny(AssertableDiagnostics.errorMsg(msgFragment));
	}
}
 
Example 5
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see SGenJavaValidator#checkDeprecatedParameters(GeneratorEntry)
 */
@Test
public void checkEntriesExist() {
	EObject model = parseExpression("GeneratorModel for yakindu::java {}", GeneratorModel.class.getSimpleName());
	if (!(model instanceof GeneratorModel)) {
		fail("Model is of the wrong type");
	} else {
		GeneratorModel genModel = (GeneratorModel) model;
		AssertableDiagnostics result = tester.validate(genModel);
		result.assertAny(new MsgPredicate(EMPTY_SGEN));
	}
}
 
Example 6
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see SGenJavaValidator#checkRequiredParameters(FeatureConfiguration)
 */
@Test
public void checkRequiredParameters() {
	EObject model = parseExpression("GeneratorModel for yakindu::java { statechart Example { feature Outlet {}}}",
			GeneratorModel.class.getSimpleName());
	AssertableDiagnostics result = tester.validate(model);
	result.assertAny(new MsgPredicate(MISSING_REQUIRED_PARAMETER));
}
 
Example 7
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see SGenJavaValidator#checkRequiredFeatures(org.yakindu.sct.model.sgen.GeneratorEntry)
 */
@Test
public void checkRequiredFeatures() {
	EObject model = parseExpression("GeneratorModel for yakindu::java { statechart Example {}}",
			GeneratorModel.class.getSimpleName());
	AssertableDiagnostics result = tester.validate(model);
	result.assertAny(new MsgPredicate(MISSING_REQUIRED_FEATURE));
}
 
Example 8
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see SGenJavaValidator#checkDuplicateFeatureParameter(org.yakindu.sct.model.sgen.FeatureParameterValue)
 */
@Test
public void checkDuplicateFeatureParameter() {
	EObject model = parseExpression(
			"GeneratorModel for yakindu::java { statechart Example { feature Outlet { targetFolder = true  targetFolder = true }}}",
			GeneratorModel.class.getSimpleName());
	AssertableDiagnostics result = tester.validate(model);
	result.assertAny(new MsgPredicate(DUPLICATE_PARAMETER));
}
 
Example 9
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see SGenJavaValidator#checkDuplicateGeneratorEntryFeature(FeatureConfiguration)
 */
@Test
public void checkDuplicateGeneratorEntryFeature() {
	EObject model = parseExpression(
			"GeneratorModel for yakindu::java { statechart Example { feature Outlet { } feature Outlet { }}}",
			GeneratorModel.class.getSimpleName());
	AssertableDiagnostics result = tester.validate(model);
	result.assertAny(new MsgPredicate(DUPLICATE_FEATURE));
}
 
Example 10
Source File: SynchronizationValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void synchronizationTransitionCount() {
	Statechart statechart = loadStatechart("SynchronizationTransitionCount.sct");
	AssertableDiagnostics diagnostics = tester.validate(statechart);
	diagnostics.assertDiagnosticsCount(2);
	diagnostics.assertAny(errorCode(SYNCHRONIZATION_TRANSITIONS_REQUIRE_MULTIPLE_IN_OR_MULTIPLE_OUT_CODE));
}
 
Example 11
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @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."));
}
 
Example 12
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void checkInitialValue() {
	EObject model = parseExpression("GeneratorModel for yakindu::java { var x : boolean = 5 }",
			GeneratorModel.class.getSimpleName());
	AssertableDiagnostics result = tester.validate(model);
	result.assertAny(new MsgPredicate("Incompatible types boolean and integer."));
}
 
Example 13
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see SGenJavaValidator#checkContentType(org.yakindu.sct.model.sgen.GeneratorEntry)
 */
@Test
public void checkContentType() {
	EObject model = parseExpression("GeneratorModel for yakindu::java { unkownType Example {}}",
			GeneratorModel.class.getSimpleName());
	AssertableDiagnostics result = tester.validate(model);
	result.assertAny(new MsgPredicate(UNKNOWN_CONTENT_TYPE));
}
 
Example 14
Source File: SGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see SGenJavaValidator#checkDomainCompatibility(GeneratorModel)
 */
@Test
public void checkDomainCompatibility() {
	EObject model = parseExpression("GeneratorModel for yakindu::java { statechart UnknownDomainStatechart { }}",
			GeneratorModel.class.getSimpleName());
	AssertableDiagnostics result = tester.validate(model);
	result.assertAny(new MsgPredicate(
			"This generator can not be used for domain does.not.exist. Valid domains are [com.yakindu.domain.java, org.yakindu.domain.default]"));
}
 
Example 15
Source File: SynchronizationValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void orthogonalTargetStates_StateInTopLevelRegion() {
	Statechart statechart = loadStatechart("NotOrthogonalRegion02.sct");
	AssertableDiagnostics diagnostics = tester.validate(statechart);
	diagnostics.assertDiagnosticsCount(2);
	diagnostics.assertAny(errorCode(SYNCHRONIZATION_REQUIRES_ORTHOGONAL_SOURCE_STATES_CODE));
	diagnostics.assertAny(errorCode(SYNCHRONIZATION_REQUIRES_ORTHOGONAL_TARGET_STATES_CODE));
}
 
Example 16
Source File: SynchronizationValidatorTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void orthogonalTargetStates_StateInParentStateRegion() {
	Statechart statechart = loadStatechart("NotOrthogonalRegion01.sct");
	AssertableDiagnostics diagnostics = tester.validate(statechart);
	diagnostics.assertDiagnosticsCount(2);
	diagnostics.assertAny(errorCode(SYNCHRONIZATION_REQUIRES_ORTHOGONAL_SOURCE_STATES_CODE));
	diagnostics.assertAny(errorCode(SYNCHRONIZATION_REQUIRES_ORTHOGONAL_TARGET_STATES_CODE));
}
 
Example 17
Source File: CSGenJavaValidatorTest.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
@Test
public void checkFeatureConfiguration() {
	EObject model = null;
	AssertableDiagnostics result = null;

	String start = "GeneratorModel for yakindu::c { statechart Example {";

	model = parseExpression(start + "feature OutEventAPI {observables = false}}}",
			GeneratorModel.class.getSimpleName());
	result = tester.validate(model);
	result.assertAny(
			new MsgPredicate(String.format(CDefaultFeatureValueProvider.REQUIRED_TRUE_PARAMETER, "OutEventAPI")));

	model = parseExpression(start + "feature OutEventAPI {observables = false getters = false}}}",
			GeneratorModel.class.getSimpleName());
	result = tester.validate(model);
	result.assertAny(
			new MsgPredicate(String.format(CDefaultFeatureValueProvider.REQUIRED_TRUE_PARAMETER, "OutEventAPI")));

	model = parseExpression(start + " feature OutEventAPI {observables = true}}}",
			GeneratorModel.class.getSimpleName());
	result = tester.validate(model);
	result.assertDiagnosticsCount(1);

	model = parseExpression(start + "feature OutEventAPI {observables = true getters = true}}}",
			GeneratorModel.class.getSimpleName());
	result = tester.validate(model);
	result.assertDiagnosticsCount(1);

	model = parseExpression(start + "feature OutEventAPI {observables = true getters = false}}}",
			GeneratorModel.class.getSimpleName());
	result = tester.validate(model);
	result.assertDiagnosticsCount(1);

	model = parseExpression(start + "feature OutEventAPI {observables = false getters = true}}}",
			GeneratorModel.class.getSimpleName());
	result = tester.validate(model);
	result.assertDiagnosticsCount(1);

	model = parseExpression(start + "feature OutEventAPI {getters = true}}}", GeneratorModel.class.getSimpleName());
	result = tester.validate(model);
	result.assertDiagnosticsCount(1);

	model = parseExpression(start + "feature OutEventAPI {getters = false}}}",
			GeneratorModel.class.getSimpleName());
	result = tester.validate(model);
	result.assertDiagnosticsCount(1);
}