Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2021-08-05 14:42:33 +0000
committerPatrick Tessier2021-08-30 08:37:41 +0000
commitf7d5202c473b69174dc84344490aa8edb3da30fd (patch)
tree10dd9ae357318aa5367798f42e84f142660154c9 /tests/junit
parentf3c2383f730cfe0a3ed7ff5a3ee241396d6dd51a (diff)
downloadorg.eclipse.papyrus-f7d5202c473b69174dc84344490aa8edb3da30fd.tar.gz
org.eclipse.papyrus-f7d5202c473b69174dc84344490aa8edb3da30fd.tar.xz
org.eclipse.papyrus-f7d5202c473b69174dc84344490aa8edb3da30fd.zip
Bug 574690: [Toolsmiths - Quickfixes] Add folder to build.properties should ignore nested folders
- update the quick fix to add the topmost folder to the build, not the immediate container of the file Change-Id: Ie9a4813945066ae0666cdd77053393b1be2aff6e Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
Diffstat (limited to 'tests/junit')
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/AllTests.java1
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/ResourceMissingFromBinaryBuilderMarkerResolutionTest.java117
2 files changed, 118 insertions, 0 deletions
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/AllTests.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/AllTests.java
index 41a72e83375..1f3c8a3ebe3 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/AllTests.java
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/AllTests.java
@@ -28,6 +28,7 @@ import org.junit.runners.Suite.SuiteClasses;
ProjectManagementUtilsTest.class,
AbstractMissingExtensionMarkerResolutionTest.class,
AbstractMissingAttributeMarkerResolutionTest.class,
+ ResourceMissingFromBinaryBuilderMarkerResolutionTest.class,
})
public class AllTests {
// Suite is specified in annotations
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/ResourceMissingFromBinaryBuilderMarkerResolutionTest.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/ResourceMissingFromBinaryBuilderMarkerResolutionTest.java
new file mode 100644
index 00000000000..eda1b3830a5
--- /dev/null
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/ResourceMissingFromBinaryBuilderMarkerResolutionTest.java
@@ -0,0 +1,117 @@
+/*****************************************************************************
+ * Copyright (c) 2021 Christian W. Damus, CEA LIST, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.toolsmiths.validation.common.tests;
+
+import static org.eclipse.papyrus.junit.matchers.MoreMatchers.regexContains;
+import static org.eclipse.papyrus.toolsmiths.validation.common.checkers.CommonProblemConstants.BINARY_BUILD_PATH;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.Map;
+import java.util.stream.Stream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.papyrus.toolsmiths.validation.common.quickfix.AbstractMissingAttributeMarkerResolution;
+import org.eclipse.papyrus.toolsmiths.validation.common.quickfix.ResourceMissingFromBinaryBuildMarkerResolution;
+import org.eclipse.papyrus.toolsmiths.validation.common.tests.rules.Build;
+import org.eclipse.papyrus.toolsmiths.validation.common.tests.rules.TestProject;
+import org.eclipse.papyrus.toolsmiths.validation.common.tests.rules.TestProjectFixture;
+import org.eclipse.ui.IMarkerResolution;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Specific test cases for the {@link AbstractMissingAttributeMarkerResolution} class.
+ */
+@TestProject("org.eclipse.papyrus.toolsmiths.validation.common.example")
+@Build(false)
+public class ResourceMissingFromBinaryBuilderMarkerResolutionTest {
+
+ @Rule
+ public final TestProjectFixture project = new TestProjectFixture();
+
+ /**
+ * Verify that the marker resolution generates the expected file entry in the <tt>build.properties</tt>.
+ */
+ @Test
+ public void addFile() {
+ IFile build = project.getFile("build.properties");
+
+ IMarker marker = project.mockMarker(build, Map.of(BINARY_BUILD_PATH, "folder/file.txt"));
+
+ IMarkerResolution fix = getFileFix(marker);
+ fix.run(marker);
+
+ String fileContent = project.getContent(build);
+ assertThat(fileContent, regexContains(
+ "(?ms),\\s*folder/file.txt"));
+ }
+
+ /**
+ * Verify that the marker resolution generates the expected folder entry in the <tt>build.properties</tt>.
+ */
+ @Test
+ public void addFolder() {
+ IFile build = project.getFile("build.properties");
+
+ IMarker marker = project.mockMarker(build, Map.of(BINARY_BUILD_PATH, "folder/file.txt"));
+
+ IMarkerResolution fix = getFolderFix(marker);
+ fix.run(marker);
+
+ String fileContent = project.getContent(build);
+ assertThat(fileContent, regexContains(
+ "(?ms),\\s*folder/(,\\s*\\??)?\n"));
+ }
+
+ /**
+ * Verify that the marker resolution generates the expected folder entry in the <tt>build.properties</tt>
+ * when the file is in a nested folder.
+ */
+ @Test
+ public void addFolder_withNesting() {
+ IFile build = project.getFile("build.properties");
+
+ IMarker marker = project.mockMarker(build, Map.of(BINARY_BUILD_PATH, "folder/nested/deeply/file.txt"));
+
+ IMarkerResolution fix = getFolderFix(marker);
+ fix.run(marker);
+
+ String fileContent = project.getContent(build);
+ assertThat(fileContent, regexContains(
+ "(?ms),\\s*folder/(,\\s*\\??)?\n"));
+ }
+
+
+ //
+ // Test framework
+ //
+
+ IMarkerResolution getFileFix(IMarker marker) {
+ IMarkerResolution[] result = ResourceMissingFromBinaryBuildMarkerResolution.forMarker(marker);
+ return Stream.of(result).filter(fix -> fix.getClass().getName().contains("$File"))
+ .findAny()
+ .orElseThrow(() -> new AssertionError("No file-specific fix obtains"));
+ }
+
+ IMarkerResolution getFolderFix(IMarker marker) {
+ IMarkerResolution[] result = ResourceMissingFromBinaryBuildMarkerResolution.forMarker(marker);
+ return Stream.of(result).filter(fix -> fix.getClass().getName().contains("$Folder"))
+ .findAny()
+ .orElseThrow(() -> new AssertionError("No file-specific fix obtains"));
+ }
+
+}

Back to the top