use of org.eclipse.emf.common.util.BasicDiagnostic in project statecharts by Yakindu.
the class SGraphJavaValidationTest method disallowTrigger.
@Test
public void disallowTrigger() {
prepareStateTest();
Entry entry = factory.createEntry();
region.getVertices().add(entry);
Transition trans = createTransition(entry, state);
trans.setTrigger(sTextFactory.createReactionTrigger());
diagnostics = new BasicDiagnostic();
assertFalse(validator.validate(entry, diagnostics, new HashMap<Object, Object>()));
assertError(diagnostics, ISSUE_ENTRY_WITH_TRIGGER);
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project statecharts by Yakindu.
the class SGraphJavaValidationTest method checkStatechartNameIsIdentifier.
@Test
public void checkStatechartNameIsIdentifier() {
Statechart statechart = SGraphFactory.eINSTANCE.createStatechart();
statechart.setName("Not a valid identifier");
validator.validate(statechart, diagnostics, new HashMap<Object, Object>());
assertIssueCount(diagnostics, 1);
assertError(diagnostics, String.format(ISSUE_STATECHART_NAME_NO_IDENTIFIER, statechart.getName()));
diagnostics = new BasicDiagnostic();
statechart.setName("0Notavalididentifier");
validator.validate(statechart, diagnostics, new HashMap<Object, Object>());
assertIssueCount(diagnostics, 1);
assertError(diagnostics, String.format(ISSUE_STATECHART_NAME_NO_IDENTIFIER, statechart.getName()));
diagnostics = new BasicDiagnostic();
statechart.setName("ValidIdentifier");
validator.validate(statechart, diagnostics, new HashMap<Object, Object>());
assertIssueCount(diagnostics, 0);
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project xtext-core by eclipse.
the class CompositeEValidatorTest method testNoShortCircuiting.
/**
* Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=396726
*/
@Test
public void testNoShortCircuiting() {
CompositeEValidator compositeValidator = new CompositeEValidator();
compositeValidator.setEqualitySupportProvider(CompositeEValidator.EValidatorEqualitySupport::new);
assertEquals(1, compositeValidator.getContents().size());
compositeValidator.addValidator(EcoreValidator.INSTANCE);
assertEquals(2, compositeValidator.getContents().size());
TestEcoreValidator testValidator = new TestEcoreValidator();
compositeValidator.addValidator(testValidator);
assertEquals(3, compositeValidator.getContents().size());
compositeValidator.validate(EcoreFactory.eINSTANCE.createEClass(), new BasicDiagnostic(), null);
assertTrue(testValidator.wasCalled());
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project xtext-core by eclipse.
the class DiagnosticTreeIterableTest method testIteratorIsNotConsumed.
@Test
public void testIteratorIsNotConsumed() {
BasicDiagnostic root = new BasicDiagnostic();
root.add(new BasicDiagnostic());
AssertableDiagnostics diagnostics = new AssertableDiagnostics(root);
Iterable<Diagnostic> allDiagnostics = diagnostics.getAllDiagnostics();
Iterator<Diagnostic> first = allDiagnostics.iterator();
while (first.hasNext()) {
first.next();
}
Assert.assertTrue(allDiagnostics.iterator().hasNext());
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project xtext-core by eclipse.
the class InjectableValidatorTest method testCorrectResource.
@Test
public void testCorrectResource() throws Exception {
Main main = LangATestLanguageFactory.eINSTANCE.createMain();
xtextResource.getContents().add(main);
assertFalse(languageSpecificValidator.validate(main, new BasicDiagnostic(), null));
assertFalse(languageSpecificValidator.validate(main, new BasicDiagnostic(), context));
assertEquals(xtextResource.getLanguageName(), context.get(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME));
context.clear();
assertFalse(languageAgnosticValidator.validate(main, new BasicDiagnostic(), null));
assertFalse(languageAgnosticValidator.validate(main, new BasicDiagnostic(), context));
assertNull(context.get(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME));
}
Aggregations