Search in sources :

Example 1 with AssertableDiagnostics

use of org.eclipse.xtext.testing.validation.AssertableDiagnostics 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 2 with AssertableDiagnostics

use of org.eclipse.xtext.testing.validation.AssertableDiagnostics in project xtext-core by eclipse.

the class ValidatorTester method diagnose.

public AssertableDiagnostics diagnose() {
    if (!validatorCalled)
        throw new IllegalStateException("You have to call validator() before you call diagnose()");
    validatorCalled = false;
    AssertableDiagnostics ad = new AssertableDiagnostics((Diagnostic) validator.setMessageAcceptor(validator).getState().chain);
    validator.setMessageAcceptor(validator).getState().chain = new BasicDiagnostic();
    return ad;
}
Also used : AssertableDiagnostics(org.eclipse.xtext.testing.validation.AssertableDiagnostics) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic)

Example 3 with AssertableDiagnostics

use of org.eclipse.xtext.testing.validation.AssertableDiagnostics in project xtext-core by eclipse.

the class AbstractConcreteSyntaxValidationTest method validate.

protected AssertableDiagnostics validate(EObject obj) {
    final BasicDiagnostic dc = new BasicDiagnostic();
    getValidator().validateRecursive(obj, new DiagnosticChainAcceptor(dc), new HashMap<Object, Object>());
    return new AssertableDiagnostics(dc);
}
Also used : AssertableDiagnostics(org.eclipse.xtext.testing.validation.AssertableDiagnostics) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) EObject(org.eclipse.emf.ecore.EObject) DiagnosticChainAcceptor(org.eclipse.xtext.validation.IConcreteSyntaxValidator.DiagnosticChainAcceptor)

Aggregations

BasicDiagnostic (org.eclipse.emf.common.util.BasicDiagnostic)3 AssertableDiagnostics (org.eclipse.xtext.testing.validation.AssertableDiagnostics)3 Diagnostic (org.eclipse.emf.common.util.Diagnostic)1 EObject (org.eclipse.emf.ecore.EObject)1 DiagnosticChainAcceptor (org.eclipse.xtext.validation.IConcreteSyntaxValidator.DiagnosticChainAcceptor)1 Test (org.junit.Test)1