Skip to content

Commit

Permalink
[4416] Ensure that all tests are running on the same tests data
Browse files Browse the repository at this point in the history
Bug: #4416
Signed-off-by: Stéphane Bégaudeau <[email protected]>
  • Loading branch information
sbegaudeau committed Jan 17, 2025
1 parent fba825c commit a491c02
Show file tree
Hide file tree
Showing 148 changed files with 1,725 additions and 1,110 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

=== Breaking changes

- https://github.com/eclipse-sirius/sirius-web/issues/4416[#4416] [sirius-web] Tests written for Sirius Web should now leverage the brand new annotation `@GivenSiriusWebServer` which will set up all the test data of the server.
It will allow us to create more complex test data shared by all integration tests to detect additional problems.
- https://github.com/eclipse-sirius/sirius-web/issues/4416[#4416] [sirius-web] The `IEditingContextMigrationParticipantPredicate` will now use the id of the editing context instead of the whole editing context in order to find out if the migration participant should be activated.


=== Dependency update

Expand All @@ -48,6 +52,9 @@ This may have some consequences for downstream applications which are embedding
See https://github.com/mui/material-ui/issues/15618[this link] for additional details.
- https://github.com/eclipse-sirius/sirius-web/issues/4360[#4360] [table] Prevent application crash when opening tables from a form
- https://github.com/eclipse-sirius/sirius-web/issues/4359[#4359] [table] Fix an issue where two pagination forms where display in tables
- https://github.com/eclipse-sirius/sirius-web/issues/4416[#4416] [sirius-web] Fix the way migration participant were executed.
Before this contribution, migration participants were executed if the project being opened was a studio.
Now they are executed for some data if the data was coming from a studio too.


=== New Features
Expand Down
1 change: 1 addition & 0 deletions packages/sirius-web/backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<module>sirius-web</module>

<module>sirius-web-tests</module>
<module>sirius-web-tests-data</module>
<module>sirius-web-e2e-tests</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -68,7 +68,7 @@ public UploadFileLoader(IMessageService messageService, IProxyValidator proxyVal
@Override
public IResult<Resource> load(ResourceSet resourceSet, IEMFEditingContext emfEditingContext, UploadFile file) {
var fileName = file.getName();
var applyMigrationParticipants = this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(emfEditingContext));
var applyMigrationParticipants = this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(emfEditingContext.getId()));
var optionalContent = this.getContent(resourceSet, file, applyMigrationParticipants);
if (optionalContent.isPresent()) {
var content = optionalContent.get();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -79,7 +79,7 @@ private void loadSemanticData(EditingContext editingContext, SemanticData semant
resourceSet.getLoadOptions().put(JsonResource.OPTION_SCHEMA_LOCATION, true);

semanticData.getDocuments().forEach(document -> this.resourceLoader.toResource(resourceSet, document.getId().toString(), document.getName(), document.getContent(),
this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(editingContext))));
this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(editingContext.getId()))));

// The ECrossReferenceAdapter must be set after the resource loading because it needs to resolve proxies in case
// of inter-resources references
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -14,7 +14,6 @@

import java.util.Objects;

import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.web.application.editingcontext.services.api.IEditingContextMigrationParticipantPredicate;
import org.eclipse.sirius.web.application.studio.services.api.IStudioCapableEditingContextPredicate;
import org.springframework.stereotype.Service;
Expand All @@ -34,7 +33,7 @@ public EditingContextMigrationParticipantHandler(IStudioCapableEditingContextPre
}

@Override
public boolean test(IEditingContext editingContextId) {
public boolean test(String editingContextId) {
return this.studioCapableEditingContextPredicate.test(editingContextId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void persist(ICause cause, IEditingContext editingContext) {
long start = System.currentTimeMillis();

if (editingContext instanceof IEMFEditingContext emfEditingContext) {
var applyMigrationParticipants = this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(emfEditingContext));
var applyMigrationParticipants = this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(emfEditingContext.getId()));
new UUIDParser().parse(editingContext.getId())
.map(AggregateReference::<Project, UUID>to)
.ifPresent(project -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -14,13 +14,11 @@

import java.util.function.Predicate;

import org.eclipse.sirius.components.core.api.IEditingContext;

/**
* Used to indicate if the editing context is concern by the migration participants.
*
* @author frouene
*/
public interface IEditingContextMigrationParticipantPredicate extends Predicate<IEditingContext> {
public interface IEditingContextMigrationParticipantPredicate extends Predicate<String> {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -96,7 +96,7 @@ public void preProcess(IEditingContext editingContext) {
this.studioColorPalettesLoader.loadStudioColorPalettes(resourceSet);

semanticData.getDocuments().forEach(document -> this.resourceLoader.toResource(resourceSet, document.getId().toString(), document.getName(), document.getContent(),
this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(editingContext))));
this.migrationParticipantPredicates.stream().anyMatch(predicate -> predicate.test(semanticData.getProject().getId().toString()))));
resourceSet.eAdapters().add(new EditingContextCrossReferenceAdapter());

var treeIterator = resourceSet.getAllContents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -39,7 +39,7 @@ public HideStudioColorPalettesTreeAlteredContentProvider(IStudioCapableEditingCo

@Override
public boolean canHandle(IEditingContext editingContext, List<String> activeFilterIds) {
var isStudio = this.studioCapableEditingContextPredicate.test(editingContext);
var isStudio = this.studioCapableEditingContextPredicate.test(editingContext.getId());
return isStudio && activeFilterIds.contains(StudioExplorerTreeFilterProvider.HIDE_STUDIO_COLOR_PALETTES_TREE_FILTER_ID);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -14,7 +14,6 @@

import java.util.Objects;

import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.web.application.UUIDParser;
import org.eclipse.sirius.web.application.studio.services.api.IStudioCapableEditingContextPredicate;
import org.eclipse.sirius.web.domain.boundedcontexts.project.Nature;
Expand All @@ -37,8 +36,8 @@ public StudioCapableEditingContextPredicate(IProjectSearchService projectSearchS
}

@Override
public boolean test(IEditingContext editingContext) {
return new UUIDParser().parse(editingContext.getId())
public boolean test(String editingContextId) {
return new UUIDParser().parse(editingContextId)
.flatMap(this.projectSearchService::findById)
.filter(this::isStudio)
.isPresent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -50,7 +50,7 @@ public StudioEditingContextActionProvider(IStudioCapableEditingContextPredicate
public List<EditingContextAction> getEditingContextAction(IEditingContext editingContext) {
var actions = new ArrayList<EditingContextAction>();

var isStudio = this.studioCapableEditingContextPredicate.test(editingContext);
var isStudio = this.studioCapableEditingContextPredicate.test(editingContext.getId());
if (isStudio && editingContext instanceof IEMFEditingContext emfEditingContext) {
var nsURIs = emfEditingContext.getDomain().getResourceSet().getPackageRegistry().values()
.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -53,7 +53,7 @@ public StudioEditingContextInitializer(IStudioCapableEditingContextPredicate stu

@Override
public void preProcess(IEditingContext editingContext) {
var isStudio = this.studioCapableEditingContextPredicate.test(editingContext);
var isStudio = this.studioCapableEditingContextPredicate.test(editingContext.getId());
if (isStudio && editingContext instanceof IEMFEditingContext emfEditingContext) {
var packageRegistry = emfEditingContext.getDomain().getResourceSet().getPackageRegistry();
packageRegistry.put(DomainPackage.eNS_URI, DomainPackage.eINSTANCE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -41,7 +41,7 @@ public StudioStereotypeProvider(IStudioCapableEditingContextPredicate studioCapa

@Override
public List<Stereotype> getStereotypes(IEditingContext editingContext) {
if (this.studioCapableEditingContextPredicate.test(editingContext)) {
if (this.studioCapableEditingContextPredicate.test(editingContext.getId())) {
return List.of(
new Stereotype(DOMAIN_STEREOTYPE, "Domain"),
new Stereotype(VIEW_STEREOTYPE, "View")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -14,12 +14,10 @@

import java.util.function.Predicate;

import org.eclipse.sirius.components.core.api.IEditingContext;

/**
* Used to test if an editing context is capable of supporting a studio.
*
* @author sbegaudeau
*/
public interface IStudioCapableEditingContextPredicate extends Predicate<IEditingContext> {
public interface IStudioCapableEditingContextPredicate extends Predicate<String> {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -82,7 +82,7 @@ public String getDescriptionId() {

@Override
public void preProcess(IEditingContext editingContext) {
if (editingContext instanceof EditingContext siriusWebEditingContext && this.studioCapableEditingContextPredicate.test(editingContext)) {
if (editingContext instanceof EditingContext siriusWebEditingContext && this.studioCapableEditingContextPredicate.test(editingContext.getId())) {
siriusWebEditingContext.getViews().add(this.view);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public DomainViewTreeDescriptionProvider(IStudioCapableEditingContextPredicate s

@Override
public void preProcess(IEditingContext editingContext) {
if (editingContext instanceof EditingContext siriusWebEditingContext && this.studioCapableEditingContextPredicate.test(editingContext)) {
if (editingContext instanceof EditingContext siriusWebEditingContext && this.studioCapableEditingContextPredicate.test(editingContext.getId())) {
siriusWebEditingContext.getViews().add(this.view);
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/sirius-web/backend/sirius-web-tests-data/.checkstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="Sirius" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
<filter name="FilesFromPackage" enabled="true">
<filter-data value="src/main/resources"/>
</filter>
</fileset-config>
58 changes: 58 additions & 0 deletions packages/sirius-web/backend/sirius-web-tests-data/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
34 changes: 34 additions & 0 deletions packages/sirius-web/backend/sirius-web-tests-data/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>sirius-web-tests-data</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Mon Sep 24 15:04:19 CEST 2007
eclipse.preferences.version=1
line.separator=\n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
Loading

0 comments on commit a491c02

Please sign in to comment.