Search in sources :

Example 56 with BasicDiagnostic

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);
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry) HashMap(java.util.HashMap) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Transition(org.yakindu.sct.model.sgraph.Transition) Test(org.junit.Test)

Example 57 with BasicDiagnostic

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);
}
Also used : BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Statechart(org.yakindu.sct.model.sgraph.Statechart) EObject(org.eclipse.emf.ecore.EObject) Test(org.junit.Test)

Example 58 with BasicDiagnostic

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());
}
Also used : EValidatorEqualitySupport(org.eclipse.xtext.validation.CompositeEValidator.EValidatorEqualitySupport) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Test(org.junit.Test)

Example 59 with BasicDiagnostic

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());
}
Also used : AssertableDiagnostics(org.eclipse.xtext.testing.validation.AssertableDiagnostics) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Diagnostic(org.eclipse.emf.common.util.Diagnostic) Test(org.junit.Test)

Example 60 with BasicDiagnostic

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));
}
Also used : BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Main(org.eclipse.xtext.linking.langATestLanguage.Main) Test(org.junit.Test)

Aggregations

BasicDiagnostic (org.eclipse.emf.common.util.BasicDiagnostic)107 Diagnostic (org.eclipse.emf.common.util.Diagnostic)50 EObject (org.eclipse.emf.ecore.EObject)43 EventObject (java.util.EventObject)30 CoreException (org.eclipse.core.runtime.CoreException)30 ProblemEditorPart (org.eclipse.emf.common.ui.editor.ProblemEditorPart)30 Point (org.eclipse.swt.graphics.Point)30 PartInitException (org.eclipse.ui.PartInitException)30 Test (org.junit.Test)20 List (java.util.List)13 Iterator (java.util.Iterator)8 BasicEList (org.eclipse.emf.common.util.BasicEList)8 EList (org.eclipse.emf.common.util.EList)8 WrappedException (org.eclipse.emf.common.util.WrappedException)8 Diagnostic (org.eclipse.emf.ecore.resource.Resource.Diagnostic)5 ExceptionDiagnostic (org.eclipse.xtext.diagnostics.ExceptionDiagnostic)5 Severity (org.eclipse.xtext.diagnostics.Severity)5 IDiagnosticConverter (org.eclipse.xtext.validation.IDiagnosticConverter)5 Issue (org.eclipse.xtext.validation.Issue)5 ResourceValidatorImpl (org.eclipse.xtext.validation.ResourceValidatorImpl)5