diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/.classpath b/com.avaloq.tools.ddk.check.test.runtime.tests/.classpath index a0c3adab0f..3d699c2275 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/.classpath +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/.classpath @@ -1,11 +1,6 @@ - - - - - diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/.project b/com.avaloq.tools.ddk.check.test.runtime.tests/.project index 7395f48dfd..a8ad50d1dc 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/.project +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/.project @@ -20,11 +20,6 @@ - - org.eclipse.xtext.ui.shared.xtextBuilder - - - net.sf.eclipsecs.core.CheckstyleBuilder @@ -44,7 +39,6 @@ org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature - org.eclipse.xtext.ui.shared.xtextNature net.sourceforge.pmd.eclipse.plugin.pmdNature net.sf.eclipsecs.core.CheckstyleNature edu.umd.cs.findbugs.plugin.eclipse.findbugsNature diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.check.test.runtime.tests/META-INF/MANIFEST.MF index 1154b3c5e0..b0f80dac1c 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/META-INF/MANIFEST.MF @@ -15,8 +15,6 @@ Require-Bundle: com.avaloq.tools.ddk.check.runtime.core, org.eclipse.xtext.testing, org.eclipse.xtext.ui.testing, org.eclipse.ui.workbench;resolution:=optional, - org.eclipse.xtend.lib, - org.eclipse.xtext.xbase.lib, junit-jupiter-api, junit-jupiter-engine, junit-platform-suite-api, diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/build.properties b/com.avaloq.tools.ddk.check.test.runtime.tests/build.properties index 57a52eb790..2ae3772a83 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/build.properties +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/build.properties @@ -1,5 +1,4 @@ source.. = src/,\ - xtend-gen/,\ resource/ output.. = bin/ bin.includes = META-INF/,\ diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.xtend b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.java similarity index 54% rename from com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.xtend rename to com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.java index 034415f296..439fbe7592 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.xtend +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckConfigurationIsAppliedTest.java @@ -8,33 +8,37 @@ * Contributors: * Avaloq Group AG - initial API and implementation *******************************************************************************/ -package com.avaloq.tools.ddk.check.test.runtime +package com.avaloq.tools.ddk.check.test.runtime; -import com.avaloq.tools.ddk.check.TestLanguageUiInjectorProvider -import com.avaloq.tools.ddk.check.core.test.AbstractCheckTestCase -import com.avaloq.tools.ddk.check.testLanguage.Model -import com.avaloq.tools.ddk.check.testLanguage.TestLanguagePackage -import com.avaloq.tools.ddk.check.ui.internal.TestLanguageActivator -import com.avaloq.tools.ddk.check.validation.ExecutionEnvironmentIssueCodes -import com.google.common.collect.Lists -import com.google.inject.Inject -import java.util.List -import org.eclipse.xtext.testing.InjectWith -import org.eclipse.xtext.testing.validation.ValidationTestHelper -import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil -import org.junit.jupiter.api.Test -import org.eclipse.xtext.testing.extensions.InjectionExtension -import org.junit.jupiter.api.^extension.ExtendWith +import java.util.List; -@InjectWith(typeof(TestLanguageUiInjectorProvider)) -@ExtendWith(typeof(InjectionExtension)) -class CheckConfigurationIsAppliedTest extends AbstractCheckTestCase { +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.eclipse.xtext.testing.validation.ValidationTestHelper; +import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.avaloq.tools.ddk.check.TestLanguageUiInjectorProvider; +import com.avaloq.tools.ddk.check.core.test.AbstractCheckTestCase; +import com.avaloq.tools.ddk.check.testLanguage.Model; +import com.avaloq.tools.ddk.check.testLanguage.TestLanguagePackage; +import com.avaloq.tools.ddk.check.ui.internal.TestLanguageActivator; +import com.avaloq.tools.ddk.check.validation.ExecutionEnvironmentIssueCodes; +import com.google.inject.Inject; +import com.google.inject.Injector; + +@InjectWith(TestLanguageUiInjectorProvider.class) +@ExtendWith(InjectionExtension.class) +@SuppressWarnings("nls") +public class CheckConfigurationIsAppliedTest extends AbstractCheckTestCase { @Inject - ValidationTestHelper helper + private ValidationTestHelper helper; - override getInjector() { - TestLanguageActivator::instance.getInjector(TestLanguageActivator::COM_AVALOQ_TOOLS_DDK_CHECK_TESTLANGUAGE) + @Override + public Injector getInjector() { + return TestLanguageActivator.getInstance().getInjector(TestLanguageActivator.COM_AVALOQ_TOOLS_DDK_CHECK_TESTLANGUAGE); } /* @@ -43,8 +47,8 @@ override getInjector() { * Eclipse has the Check runtime plugins installed, code will automatically be generated * for those resources. In order to avoid that the file extensions have been ommitted. */ - def List getRequiredSourceFileNames() { - Lists::newArrayList('.settings/com.avaloq.tools.ddk.checkcfg.core.prefs', 'Greetings') + public List getRequiredSourceFileNames() { + return List.of(".settings/com.avaloq.tools.ddk.checkcfg.core.prefs", "Greetings"); } /* @@ -52,13 +56,13 @@ def List getRequiredSourceFileNames() { * and applied: the severity is changed from ERROR to WARNING. */ @Test - def void testCheckConfigurationIsApplied() { + public void testCheckConfigurationIsApplied() throws Exception { // sources are copied into the project and then built by the Xtext builder - addSourcesToWorkspace(typeof(CheckConfigurationIsAppliedTest), requiredSourceFileNames) + addSourcesToWorkspace(CheckConfigurationIsAppliedTest.class, getRequiredSourceFileNames()); // wait for build to finish, otherwise included catalog may not be resolvable - IResourcesSetupUtil::waitForBuild - val model = getModel("Greetings") as Model - helper.assertWarning(model.greetings.get(0), TestLanguagePackage$Literals::GREETING, ExecutionEnvironmentIssueCodes::FRANZNAME) + IResourcesSetupUtil.waitForBuild(); + final Model model = (Model) getModel("Greetings"); + helper.assertWarning(model.getGreetings().get(0), TestLanguagePackage.Literals.GREETING, ExecutionEnvironmentIssueCodes.FRANZNAME); } } diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.java b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.java new file mode 100644 index 0000000000..03bcb8f9e3 --- /dev/null +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2016 Avaloq Group AG and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Avaloq Group AG - initial API and implementation + *******************************************************************************/ +package com.avaloq.tools.ddk.check.test.runtime; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.eclipse.xtext.testing.util.ParseHelper; +import org.eclipse.xtext.testing.validation.ValidationTestHelper; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.avaloq.tools.ddk.check.TestLanguageUiInjectorProvider; +import com.avaloq.tools.ddk.check.core.test.AbstractCheckTestCase; +import com.avaloq.tools.ddk.check.testLanguage.Model; +import com.avaloq.tools.ddk.check.testLanguage.TestLanguagePackage; +import com.avaloq.tools.ddk.check.ui.internal.TestLanguageActivator; +import com.avaloq.tools.ddk.check.validation.ExecutionEnvironmentIssueCodes; +import com.avaloq.tools.ddk.check.validation.LibraryChecksIssueCodes; +import com.google.inject.Inject; +import com.google.inject.Injector; + + +@InjectWith(TestLanguageUiInjectorProvider.class) +@ExtendWith(InjectionExtension.class) +@SuppressWarnings("nls") +public class CheckExecutionEnvironmentProjectTest extends AbstractCheckTestCase { + + @Inject + private ValidationTestHelper helper; + + @Inject + private ParseHelper parser; + + @Override + public Injector getInjector() { + return TestLanguageActivator.getInstance().getInjector(TestLanguageActivator.COM_AVALOQ_TOOLS_DDK_CHECK_TESTLANGUAGE); + } + + @Test + public void testFranz() throws Exception { + final Model model = parser.parse("Hello Franz!"); + helper.assertError(model, TestLanguagePackage.Literals.GREETING, ExecutionEnvironmentIssueCodes.FRANZNAME); + } + + @Test + public void testFrans() throws Exception { + final Model model = parser.parse("Hello Frans!"); + helper.assertNoError(model, ExecutionEnvironmentIssueCodes.FRANZNAME); + helper.assertNoError(model, ExecutionEnvironmentIssueCodes.NAMELENGTH); + } + + @Test + public void testGreetingNameIssue() throws Exception { + final Model model = parser.parse("Hello GreetingNameTooLong!"); + helper.assertError(model, TestLanguagePackage.Literals.GREETING, ExecutionEnvironmentIssueCodes.NAMELENGTH); + } + + /* + * Tests that both validations emerging from the Java validator as well as such emerging from the check based + * validator appear. (Fixed by CheckCompositeEValidator). + */ + @Test + //@BugTest("AIG-709") // this plugin should be ACF independent + public void testBugAig709() throws Exception { + final Model model = parser.parse("Hello GreetingNameTooLong!"); + helper.assertError(model, TestLanguagePackage.Literals.GREETING, ExecutionEnvironmentIssueCodes.NAMELENGTH); + helper.assertWarning(model, TestLanguagePackage.Literals.GREETING, IssueCodesConstants.GREETING_NAME_PREFIX); + } + + @Test + public void testLibraryInjection() throws Exception { + final Model model = parser.parse("Hello Peter!"); + helper.assertWarning(model, TestLanguagePackage.Literals.GREETING, LibraryChecksIssueCodes.CHECK_CATALOG_IS_ACTIVE); + helper.assertNoError(model, LibraryChecksIssueCodes.CACHE_DOESNT_WORK); + helper.assertNoError(model, LibraryChecksIssueCodes.CACHE_INJECTION_FAILED); + helper.assertNoError(model, LibraryChecksIssueCodes.FORMAL_PARAMETERS); + } +} diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.xtend b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.xtend deleted file mode 100644 index a4d5f7cddc..0000000000 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/CheckExecutionEnvironmentProjectTest.xtend +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.check.test.runtime - -import com.avaloq.tools.ddk.check.TestLanguageUiInjectorProvider -import com.avaloq.tools.ddk.check.core.test.AbstractCheckTestCase -import com.avaloq.tools.ddk.check.testLanguage.Model -import com.avaloq.tools.ddk.check.testLanguage.TestLanguagePackage -import com.avaloq.tools.ddk.check.ui.internal.TestLanguageActivator -import com.avaloq.tools.ddk.check.validation.ExecutionEnvironmentIssueCodes -import com.avaloq.tools.ddk.check.validation.LibraryChecksIssueCodes -import com.google.inject.Inject -import org.eclipse.xtext.testing.InjectWith -import org.eclipse.xtext.testing.util.ParseHelper -import org.eclipse.xtext.testing.validation.ValidationTestHelper -import org.junit.jupiter.api.^extension.ExtendWith -import org.eclipse.xtext.testing.extensions.InjectionExtension -import org.junit.jupiter.api.Test - - -@InjectWith(typeof(TestLanguageUiInjectorProvider)) -@ExtendWith(typeof(InjectionExtension)) -class CheckExecutionEnvironmentProjectTest extends AbstractCheckTestCase { - - @Inject - ValidationTestHelper helper - - @Inject - ParseHelper parser - - override getInjector() { - TestLanguageActivator::instance.getInjector(TestLanguageActivator::COM_AVALOQ_TOOLS_DDK_CHECK_TESTLANGUAGE) - } - - @Test - def void testFranz() { - val model = parser.parse("Hello Franz!") - helper.assertError(model, TestLanguagePackage.Literals::GREETING, ExecutionEnvironmentIssueCodes::FRANZNAME) - } - - @Test - def void testFrans() { - val model = parser.parse("Hello Frans!") - helper.assertNoError(model, ExecutionEnvironmentIssueCodes::FRANZNAME) - helper.assertNoError(model, ExecutionEnvironmentIssueCodes::NAMELENGTH) - } - - @Test - def void testGreetingNameIssue() { - val model = parser.parse("Hello GreetingNameTooLong!") - helper.assertError(model, TestLanguagePackage.Literals::GREETING, ExecutionEnvironmentIssueCodes::NAMELENGTH) - } - - /* - * Tests that both validations emerging from the Java validator as well as such emerging from the check based - * validator appear. (Fixed by CheckCompositeEValidator). - */ - @Test - //@BugTest("AIG-709") // this plugin should be ACF independent - def void testBugAig709() { - val model = parser.parse("Hello GreetingNameTooLong!") - helper.assertError(model, TestLanguagePackage.Literals::GREETING, ExecutionEnvironmentIssueCodes::NAMELENGTH) - helper.assertWarning(model, TestLanguagePackage.Literals::GREETING, IssueCodesConstants::GREETING_NAME_PREFIX) - } - - @Test - def void testLibraryInjection() { - val model = parser.parse("Hello Peter!"); - helper.assertWarning(model, TestLanguagePackage.Literals::GREETING, LibraryChecksIssueCodes::CHECK_CATALOG_IS_ACTIVE); - helper.assertNoError(model, LibraryChecksIssueCodes::CACHE_DOESNT_WORK); - helper.assertNoError(model, LibraryChecksIssueCodes::CACHE_INJECTION_FAILED); - helper.assertNoError(model, LibraryChecksIssueCodes::FORMAL_PARAMETERS); - } -} diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.java b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.java new file mode 100644 index 0000000000..7a3a4113c3 --- /dev/null +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2016 Avaloq Group AG and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Avaloq Group AG - initial API and implementation + *******************************************************************************/ + +package com.avaloq.tools.ddk.check.test.runtime.label; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import com.avaloq.tools.ddk.check.runtime.label.ICheckRuleLabelProvider; +import com.avaloq.tools.ddk.check.validation.LibraryChecksIssueCodes; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; + +/** + * End-to-end test for getting Check labels. + */ +@SuppressWarnings("nls") +public class IssueLabelTest { + + /** + * End-to-end test for getting Check labels. + */ + @Test + public void testGetLabel() { + + // ARRANGE + final ICheckRuleLabelProvider checkRuleLabelProvider = Guice.createInjector(new AbstractModule() { + @Override + protected void configure() {} + }).getInstance(ICheckRuleLabelProvider.class); + + final Map expectedMap = Map.of( + LibraryChecksIssueCodes.CACHE_DOESNT_WORK, "Cache doesn't work", + LibraryChecksIssueCodes.CACHE_INJECTION_FAILED, "Cache injection failed", + LibraryChecksIssueCodes.CHECK_CATALOG_IS_ACTIVE, "Check catalog is active", + LibraryChecksIssueCodes.FORMAL_PARAMETERS, "Formal Parameters"); + + for (final Map.Entry entry : expectedMap.entrySet()) { + // ACT + final String label = checkRuleLabelProvider.getLabel(entry.getKey()); + + // ASSERT + assertNotNull(label, "Label should be returned for key " + entry.getKey()); + assertEquals(entry.getValue(), label, "Correct label should be returned for key " + entry.getKey()); + } + } +} diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.xtend b/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.xtend deleted file mode 100644 index 76989f8eb3..0000000000 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/src/com/avaloq/tools/ddk/check/test/runtime/label/IssueLabelTest.xtend +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ - -package com.avaloq.tools.ddk.check.test.runtime.label - -import com.avaloq.tools.ddk.check.runtime.label.ICheckRuleLabelProvider -import com.avaloq.tools.ddk.check.validation.LibraryChecksIssueCodes -import com.google.inject.AbstractModule -import com.google.inject.Guice -import org.junit.jupiter.api.Test -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * End-to-end test for getting Check labels. - */ -class IssueLabelTest { - - /** - * End-to-end test for getting Check labels. - */ - @Test - def testGetLabel() { - - // ARRANGE - val checkRuleLabelProvider = Guice.createInjector(new AbstractModule() { - protected override configure() {} - }).getInstance(ICheckRuleLabelProvider); - - val expectedMap = #{ - // @Format-Off - LibraryChecksIssueCodes.CACHE_DOESNT_WORK -> "Cache doesn't work", - LibraryChecksIssueCodes.CACHE_INJECTION_FAILED -> "Cache injection failed", - LibraryChecksIssueCodes.CHECK_CATALOG_IS_ACTIVE -> "Check catalog is active", - LibraryChecksIssueCodes.FORMAL_PARAMETERS -> "Formal Parameters" - // @Format-On - } - - for (entry : expectedMap.entrySet) { - // ACT - val label = checkRuleLabelProvider.getLabel(entry.key); - - // ASSERT - assertNotNull(label, "Label should be returned for key " + entry.key); - assertEquals( entry.value, label, "Correct label should be returned for key " + entry.key); - } - } -} diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/xtend-gen/.gitignore b/com.avaloq.tools.ddk.check.test.runtime.tests/xtend-gen/.gitignore deleted file mode 100644 index e69de29bb2..0000000000