diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/AbstractValidatorTester.java b/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/validation/AbstractValidatorTester.java similarity index 87% rename from org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/AbstractValidatorTester.java rename to org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/validation/AbstractValidatorTester.java index 81dbb5a4824..67a53261937 100644 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/AbstractValidatorTester.java +++ b/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/validation/AbstractValidatorTester.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2009 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2023 itemis AG (http://www.itemis.eu) and others. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ -package org.eclipse.xtext.validation; +package org.eclipse.xtext.testing.validation; import java.util.Map; @@ -14,10 +14,11 @@ import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.Diagnostician; -import org.eclipse.xtext.testing.validation.AssertableDiagnostics; /** * @author Moritz Eysholdt - Initial contribution and API + * + * @since 2.34 */ public abstract class AbstractValidatorTester { @@ -27,7 +28,7 @@ public AssertableDiagnostics validate(EDataType type, Object obj) { Diagnostic d = diagnostician.validate(type, obj); return new AssertableDiagnostics(d); } - + public AssertableDiagnostics validate(EObject obj) { Diagnostic d = diagnostician.validate(obj); return new AssertableDiagnostics(d); diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/ValidatorTester.java b/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/validation/ValidatorTester.java similarity index 89% rename from org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/ValidatorTester.java rename to org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/validation/ValidatorTester.java index 34b49d16dd6..eeace790435 100644 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/ValidatorTester.java +++ b/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/validation/ValidatorTester.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2009 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2023 itemis AG (http://www.itemis.eu) and others. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ -package org.eclipse.xtext.validation; +package org.eclipse.xtext.testing.validation; import org.eclipse.emf.common.util.BasicDiagnostic; import org.eclipse.emf.common.util.Diagnostic; @@ -14,8 +14,10 @@ import org.eclipse.emf.ecore.impl.EValidatorRegistryImpl; import org.eclipse.emf.ecore.util.Diagnostician; import org.eclipse.xtext.Constants; -import org.eclipse.xtext.testing.validation.AssertableDiagnostics; +import org.eclipse.xtext.validation.AbstractDeclarativeValidator; import org.eclipse.xtext.validation.AbstractDeclarativeValidator.State; +import org.eclipse.xtext.validation.AbstractInjectableValidator; +import org.eclipse.xtext.validation.EValidatorRegistrar; import com.google.inject.Inject; import com.google.inject.Injector; @@ -25,6 +27,8 @@ /** * @author Moritz Eysholdt - Initial contribution and API + * + * @since 2.34 */ public class ValidatorTester extends AbstractValidatorTester { @@ -37,7 +41,7 @@ public ValidatorTester(T validator, Injector injector) { injector.getInstance(EValidatorRegistrar.class), injector.getInstance(Key.get(String.class, Names.named(Constants.LANGUAGE_NAME)))); } - + @Inject public ValidatorTester(T validator, EValidatorRegistrar registrar, @Named(Constants.LANGUAGE_NAME) final String languageName) { this.validator = validator; @@ -56,7 +60,7 @@ public java.util.Map createDefaultContext() { registrar.setRegistry(originalRegistry); validatorCalled = false; } - + public AssertableDiagnostics diagnose() { if (!validatorCalled) throw new IllegalStateException("You have to call validator() before you call diagnose()"); diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/ValidatorTesterTest.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/ValidatorTesterTest.java index 1b8f053e18d..f8589168564 100644 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/ValidatorTesterTest.java +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/ValidatorTesterTest.java @@ -19,6 +19,7 @@ import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.xtext.XtextStandaloneSetup; +import org.eclipse.xtext.testing.validation.ValidatorTester; import org.eclipse.xtext.tests.AbstractXtextTests; import org.junit.Test;