Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langer2016-05-12 16:34:41 +0000
committerLaurent Delaigue2016-06-03 08:55:48 +0000
commit7ad78fe00cb8ee8108228dd30d53a9ead06a3ca3 (patch)
tree6ab1b77d75659bb5546ac7d27b8f67af322720a4 /plugins/org.eclipse.emf.compare.tests
parentea6b5f3db821d3c3cdff84a6f269ee989facadd6 (diff)
downloadorg.eclipse.emf.compare-7ad78fe00cb8ee8108228dd30d53a9ead06a3ca3.tar.gz
org.eclipse.emf.compare-7ad78fe00cb8ee8108228dd30d53a9ead06a3ca3.tar.xz
org.eclipse.emf.compare-7ad78fe00cb8ee8108228dd30d53a9ead06a3ca3.zip
Store all file URIs that have initially been in scope
With this change, we provide access to the originally selected resources in the synchronization model and the comparison scope. This information will allow us to better identify the context of a comparison or merge. Change-Id: I344ed455e77df171143ceb089c6269d207046e31 Signed-off-by: Philip Langer <planger@eclipsesource.com>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/scope/ComparisonScopeAdapterTest.java61
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java4
2 files changed, 64 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/scope/ComparisonScopeAdapterTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/scope/ComparisonScopeAdapterTest.java
new file mode 100644
index 000000000..6405999c6
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/scope/ComparisonScopeAdapterTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Services GmbH 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:
+ * Philip Langer - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.scope;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.scope.IComparisonScope2;
+import org.eclipse.emf.compare.tests.fullcomparison.data.identifier.IdentifierMatchInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.junit.Test;
+
+/**
+ * This tests whether we can obtain the {@link IComparisonScope2} from a {@link Comparison}.
+ *
+ * @author Philip Langer <planger@eclipsesource.com>
+ */
+public class ComparisonScopeAdapterTest {
+
+ private static final URI TEST_URI_1 = URI.createURI("test_uri_1"); //$NON-NLS-1$
+
+ private static final URI TEST_URI_2 = URI.createURI("test_uri_2"); //$NON-NLS-1$
+
+ @Test
+ public void testAccessingScopeFromComparison() throws IOException {
+ final IdentifierMatchInputData mockModel = new IdentifierMatchInputData();
+ final Resource left = mockModel.getExtlibraryLeft();
+ final Resource right = mockModel.getExtlibraryRight();
+ final Resource origin = mockModel.getExtlibraryOrigin();
+
+ final IComparisonScope2 scope = new DefaultComparisonScope(left, right, origin);
+ scope.getAllInvolvedResourceURIs().add(TEST_URI_1);
+ scope.getAllInvolvedResourceURIs().add(TEST_URI_2);
+
+ final Comparison comparison = EMFCompare.builder().build().compare(scope);
+ final IComparisonScope2 comparisonScope = adaptToComparisonScope(comparison);
+ assertNotNull(comparisonScope);
+ assertTrue(comparisonScope.getAllInvolvedResourceURIs().contains(TEST_URI_1));
+ assertTrue(comparisonScope.getAllInvolvedResourceURIs().contains(TEST_URI_2));
+ }
+
+ private IComparisonScope2 adaptToComparisonScope(final Comparison comparison) {
+ return (IComparisonScope2)EcoreUtil.getAdapter(comparison.eAdapters(), IComparisonScope2.class);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
index 749e98933..c8bb708cb 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
@@ -63,6 +63,7 @@ import org.eclipse.emf.compare.tests.nodes.NodesPackage;
import org.eclipse.emf.compare.tests.nodes.util.NodesResourceFactoryImpl;
import org.eclipse.emf.compare.tests.postprocess.PostProcessorTest;
import org.eclipse.emf.compare.tests.req.ReqComputingTest;
+import org.eclipse.emf.compare.tests.scope.ComparisonScopeAdapterTest;
import org.eclipse.emf.compare.tests.scope.DefaultComparisonScopeTest;
import org.eclipse.emf.compare.tests.utils.EqualityHelperTest;
import org.eclipse.emf.compare.tests.utils.MatchUtilFeatureContainsTest;
@@ -94,7 +95,8 @@ import org.junit.runners.Suite.SuiteClasses;
MultiLineAttributeConflictDetectionTest.class, ThreeWayTextDiffTest.class,
MultiLineAttributeMergeTest.class, MonitorCancelTest.class, IdentifierEObjectMatcherTest.class,
MatchUtilFeatureContainsTest.class, RefineMergeTest.class, Bug484557ConflictTest.class,
- Bug485266_MoveDeleteConflict_Test.class, ResourceAttachmentChangeBug492261.class })
+ Bug485266_MoveDeleteConflict_Test.class, ResourceAttachmentChangeBug492261.class,
+ ComparisonScopeAdapterTest.class, })
public class AllTests {
/**
* Standalone launcher for all of compare's tests.

Back to the top