Skip to content
Open
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.checkcfg.core.test/.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="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"/>
<classpathentry kind="output" path="bin"/>
Expand Down
6 changes: 0 additions & 6 deletions com.avaloq.tools.ddk.checkcfg.core.test/.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 @@ -16,7 +16,6 @@ Require-Bundle: com.avaloq.tools.ddk.test.core,
org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.core.runtime,
org.eclipse.xtend.lib,
org.eclipse.xtext.ui.testing,
org.eclipse.xtext.xbase.lib,
org.eclipse.ui.workbench;resolution:=optional,
Expand Down
3 changes: 1 addition & 2 deletions com.avaloq.tools.ddk.checkcfg.core.test/build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source.. = src/,\
xtend-gen/
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*******************************************************************************
* 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.checkcfg.contentassist;

import static com.avaloq.tools.ddk.checkcfg.CheckCfgConstants.PROPERTY_EXECUTABLE_EXTENSION_ATTRIBUTE;
import static com.avaloq.tools.ddk.checkcfg.CheckCfgConstants.PROPERTY_EXTENSION_POINT;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.extensions.InjectionExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.checkcfg.CheckCfgUiInjectorProvider;
import com.avaloq.tools.ddk.checkcfg.util.CheckCfgTestUtil;
import com.avaloq.tools.ddk.test.checkcfg.TestPropertySpecificationWithExpectedValues;
import com.avaloq.tools.ddk.test.checkcfg.TestPropertySpecificationWithOutExpectedValues;
import com.avaloq.tools.ddk.test.core.jupiter.BugTest;
import com.avaloq.tools.ddk.test.core.mock.ExtensionRegistryMock;
import com.avaloq.tools.ddk.xtext.test.jupiter.AbstractAcfContentAssistTest;
import com.avaloq.tools.ddk.xtext.test.jupiter.AbstractXtextTestUtil;

@ExtendWith(InjectionExtension.class)
@InjectWith(CheckCfgUiInjectorProvider.class)
public class CheckCfgContentAssistTest extends AbstractAcfContentAssistTest {

private static final String SOURCE_TEMPLATE = """
check configuration Test {
catalog TestChecks {
default Test (
%s = %s"banana"
)
}
}
""";

@Override
protected AbstractXtextTestUtil getXtextTestUtil() {
return CheckCfgTestUtil.getInstance();
}

@Override
protected List<String> getRequiredSourceFileNames() {
return new ArrayList<String>(0);
}

@Override
protected void beforeAllTests() {
ExtensionRegistryMock.mockExecutableExtension(ExtensionRegistryMock.mockConfigurationElement(PROPERTY_EXTENSION_POINT), PROPERTY_EXECUTABLE_EXTENSION_ATTRIBUTE, TestPropertySpecificationWithExpectedValues.INSTANCE);
ExtensionRegistryMock.mockExecutableExtension(ExtensionRegistryMock.mockConfigurationElement(PROPERTY_EXTENSION_POINT), PROPERTY_EXECUTABLE_EXTENSION_ATTRIBUTE, TestPropertySpecificationWithOutExpectedValues.INSTANCE);
super.beforeAllTests();
}

@Override
protected void afterAllTests() {
super.afterAllTests();
ExtensionRegistryMock.unMock(PROPERTY_EXTENSION_POINT);
}

@Test
public void testConfiguredParameterProposals() {
final String source = SOURCE_TEMPLATE.formatted(TestPropertySpecificationWithExpectedValues.INSTANCE.getName(), expected(TestPropertySpecificationWithExpectedValues.INSTANCE.getExpectedValues()));
assertKernelSourceProposals("ConfiguredParameterProposals.checkcfg", source);
}

@BugTest(value = "DSL-1811", unresolved = true)
public void testNoTypeMismatchedParameterValueProposals() {
final String source = SOURCE_TEMPLATE.formatted(TestPropertySpecificationWithExpectedValues.INSTANCE.getName(), expectedExactly(TestPropertySpecificationWithExpectedValues.INSTANCE.getExpectedValues()));
assertKernelSourceProposals("NoTypeMismatchedParameterValueProposals.checkcfg", source);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*******************************************************************************
* 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.checkcfg.scoping;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.scoping.IScopeProvider;

import com.avaloq.tools.ddk.checkcfg.checkcfg.CheckcfgPackage;
import com.avaloq.tools.ddk.checkcfg.util.CheckCfgTestUtil;
import com.avaloq.tools.ddk.test.core.jupiter.BugTest;
import com.avaloq.tools.ddk.xtext.test.jupiter.AbstractScopingTest;
import com.avaloq.tools.ddk.xtext.test.jupiter.AbstractXtextTestUtil;

public final class CheckCfgScopeProviderTest extends AbstractScopingTest {

private final IScopeProvider scopeProvider = getScopeProvider();

/** {@inheritDoc} */
@Override
protected AbstractXtextTestUtil getXtextTestUtil() {
return CheckCfgTestUtil.getInstance();
}

/** {@inheritDoc} */
@Override
protected void registerRequiredSources() {
}

/**
* Regression test for DSL-1498 Incorrect Catalog Name inserted by Content Assist
* <p>
* All catalogs supplied to Context Assist should be in the correct fully-qualified package.
* </p>
*/
@BugTest(value = "DSL-1498")
public void testCatalogsAreInCorrectPackage() {

// ARRANGE

final List<String> expPackageNamePrefix = List.of("com", "avaloq", "tools", "ddk");

// Define test data
final int cursorPos = getTag();
final String sourceContent = """
check configuration testCheckCfg {
%s
}
""".formatted(mark(cursorPos));

// Register a check configuration source, and get a context model
registerModel(getTestSourceFileName(), sourceContent);
final EObject context = getMarkerTagsInfo().getModel(cursorPos);
if (null == context) {
throw new IllegalStateException("Got null context model");
}

// ACT

// Get catalogs
final Iterable<IEObjectDescription> elements = scopeProvider.getScope(context, CheckcfgPackage.Literals.CONFIGURED_CATALOG__CATALOG).getAllElements();
if (!elements.iterator().hasNext()) {
throw new IllegalStateException("Scope has no elements");
}

// ASSERT

elements.forEach((IEObjectDescription element) -> {
// Check catalog has the correct fully-qualified package name
final List<String> actualName = element.getName().getSegments();
final Object[] actualPackageName = actualName.stream().limit(expPackageNamePrefix.size()).toArray();
assertArrayEquals(expPackageNamePrefix.toArray(), actualPackageName, "Catalog must have the correct fully-qualified package name");
});
}
}

This file was deleted.

Loading