Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions com.avaloq.tools.ddk.check.test.runtime.tests/.classpath
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="xtend-gen">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="resource"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
Expand Down
6 changes: 0 additions & 6 deletions com.avaloq.tools.ddk.check.test.runtime.tests/.project
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
Expand All @@ -44,7 +39,6 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
<nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source.. = src/,\
xtend-gen/,\
resource/
output.. = bin/
bin.includes = META-INF/,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand All @@ -43,22 +47,22 @@ 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<String> getRequiredSourceFileNames() {
Lists::newArrayList('.settings/com.avaloq.tools.ddk.checkcfg.core.prefs', 'Greetings')
public List<String> getRequiredSourceFileNames() {
return List.of(".settings/com.avaloq.tools.ddk.checkcfg.core.prefs", "Greetings");
}

/*
* Tests that the check configuration copied to the .settings folder of the project is read
* 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);
}

}
Original file line number Diff line number Diff line change
@@ -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<Model> 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);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<String, String> 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<String, String> 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());
}
}
}
Loading