Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2013-02-19 09:07:09 -0500
committerAxel Richard2013-03-07 05:25:33 -0500
commit9da022449f18180a7c5d3b28d9076ea96d7ae7d2 (patch)
treecbed02ae15a135f3fb67d12ddaac523a04753ef2 /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit
parent7877561fd43eaf3780115a75e9e2a567cebcd20f (diff)
downloadorg.eclipse.emf.compare-9da022449f18180a7c5d3b28d9076ea96d7ae7d2.tar.gz
org.eclipse.emf.compare-9da022449f18180a7c5d3b28d9076ea96d7ae7d2.tar.xz
org.eclipse.emf.compare-9da022449f18180a7c5d3b28d9076ea96d7ae7d2.zip
[401659] New filters and trees under groups
Display the tree structure of the model below each group. Add new filters : * Identical elements : hide elements with no differences * Pseudo conflicts elements : on a 3-way comparison, hide elements that has been made on both side. * Pseudo delete conflicts elements : on a 3-way comparison, hide deleted elements that has been made on both side. * Sub diff elements : hide differences under differences. * Uml refined elements : hide all uml elements refined by another diff. * Diagram (Gmf) refined elements : hide all gmf elements refined by another diff. Remove filters : Addes, Removes, Changed, Moved Remove Group : By Metaclass Bug: 401659 Change-Id: I97f4bcf6a2f4dc4fadec42a55c6b8adec574f536
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/AbstractTestCompareItemProviderAdapter.java248
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestMatchItemProviderSpec.java290
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestReferenceChangeItemProviderSpec.java590
3 files changed, 564 insertions, 564 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/AbstractTestCompareItemProviderAdapter.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/AbstractTestCompareItemProviderAdapter.java
index 5addcdf05..fcc6d1eec 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/AbstractTestCompareItemProviderAdapter.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/AbstractTestCompareItemProviderAdapter.java
@@ -1,124 +1,124 @@
-/*******************************************************************************
- * Copyright (c) 2012 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.tests.edit;
-
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.find;
-import static com.google.common.collect.Lists.newArrayList;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Predicate;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.compare.Comparison;
-import org.eclipse.emf.compare.EMFCompare;
-import org.eclipse.emf.compare.Match;
-import org.eclipse.emf.compare.ReferenceChange;
-import org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory;
-import org.eclipse.emf.compare.provider.spec.CompareItemProviderAdapterFactorySpec;
-import org.eclipse.emf.compare.scope.IComparisonScope;
-import org.eclipse.emf.compare.tests.edit.data.ResourceScopeProvider;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
-import org.junit.Before;
-
-/**
- * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
- */
-public class AbstractTestCompareItemProviderAdapter {
-
- protected CompareItemProviderAdapterFactory compareItemProviderAdapterFactory;
-
- @Before
- public void before() throws IOException {
- compareItemProviderAdapterFactory = new CompareItemProviderAdapterFactorySpec();
- }
-
- /**
- * @return the comparison
- * @throws IOException
- */
- protected static Comparison getComparison(ResourceScopeProvider scopeProvider) throws IOException {
- IComparisonScope scope = EMFCompare.createDefaultScope(scopeProvider.getLeft(), scopeProvider
- .getRight(), scopeProvider.getOrigin());
- return EMFCompare.builder().build().compare(scope);
- }
-
- protected Match getMatchWithFeatureValue(Collection<?> c, final String featureName, final Object value) {
- Iterable<Match> matches = filter(c, Match.class);
- Predicate<Match> predicate = hasFeatureValue(featureName, value);
- return find(matches, predicate);
- }
-
- protected ReferenceChange getReferenceChangeWithFeatureValue(Collection<?> c, final String featureName,
- final Object value) {
- Iterable<ReferenceChange> matches = filter(c, ReferenceChange.class);
- Predicate<ReferenceChange> predicate = new Predicate<ReferenceChange>() {
- public boolean apply(ReferenceChange referenceChange) {
- EObject referenceChangeValue = referenceChange.getValue();
- if (referenceChangeValue != null) {
- return Objects.equal(eGet(referenceChangeValue, featureName), value);
- }
- return false;
- }
- };
- return find(matches, predicate);
- }
-
- protected Predicate<Match> hasFeatureValue(final String featureName, final Object value) {
- Predicate<Match> predicate = new Predicate<Match>() {
- public boolean apply(Match match) {
- final boolean ret;
- final EObject left = match.getLeft();
- final EObject right = match.getRight();
- final EObject origin = match.getOrigin();
- if (left != null) {
- ret = Objects.equal(value, eGet(left, featureName));
- } else if (right != null) {
- ret = Objects.equal(value, eGet(right, featureName));
- } else if (origin != null) {
- ret = Objects.equal(value, eGet(origin, featureName));
- } else {
- ret = false;
- }
- return ret;
- }
- };
- return predicate;
- }
-
- protected Object eGet(EObject eObject, String featureName) {
- EStructuralFeature eStructuralFeature = eObject.eClass().getEStructuralFeature(featureName);
- return eObject.eGet(eStructuralFeature);
- }
-
- protected List<Notifier> eAllChildren(Notifier notifier) {
- List<Notifier> ret = newArrayList();
- ITreeItemContentProvider contentProvider = adaptAsITreItemContentProvider(notifier);
- Iterable<Notifier> children = filter(contentProvider.getChildren(notifier), Notifier.class);
- for (Notifier child : children) {
- ret.add(child);
- ret.addAll(eAllChildren(child));
- }
- return ret;
- }
-
- protected ITreeItemContentProvider adaptAsITreItemContentProvider(Notifier notifier) {
- ITreeItemContentProvider contentProvider = (ITreeItemContentProvider)compareItemProviderAdapterFactory
- .adapt(notifier, ITreeItemContentProvider.class);
- return contentProvider;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.edit;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Lists.newArrayList;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.compare.provider.CompareItemProviderAdapterFactory;
+import org.eclipse.emf.compare.provider.spec.CompareItemProviderAdapterFactorySpec;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.eclipse.emf.compare.tests.edit.data.ResourceScopeProvider;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.junit.Before;
+
+/**
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
+public class AbstractTestCompareItemProviderAdapter {
+
+ protected CompareItemProviderAdapterFactory compareItemProviderAdapterFactory;
+
+ @Before
+ public void before() throws IOException {
+ compareItemProviderAdapterFactory = new CompareItemProviderAdapterFactorySpec();
+ }
+
+ /**
+ * @return the comparison
+ * @throws IOException
+ */
+ protected static Comparison getComparison(ResourceScopeProvider scopeProvider) throws IOException {
+ IComparisonScope scope = EMFCompare.createDefaultScope(scopeProvider.getLeft(), scopeProvider
+ .getRight(), scopeProvider.getOrigin());
+ return EMFCompare.builder().build().compare(scope);
+ }
+
+ protected Match getMatchWithFeatureValue(Collection<?> c, final String featureName, final Object value) {
+ Iterable<Match> matches = filter(c, Match.class);
+ Predicate<Match> predicate = hasFeatureValue(featureName, value);
+ return find(matches, predicate);
+ }
+
+ protected ReferenceChange getReferenceChangeWithFeatureValue(Collection<?> c, final String featureName,
+ final Object value) {
+ Iterable<ReferenceChange> matches = filter(c, ReferenceChange.class);
+ Predicate<ReferenceChange> predicate = new Predicate<ReferenceChange>() {
+ public boolean apply(ReferenceChange referenceChange) {
+ EObject referenceChangeValue = referenceChange.getValue();
+ if (referenceChangeValue != null) {
+ return Objects.equal(eGet(referenceChangeValue, featureName), value);
+ }
+ return false;
+ }
+ };
+ return find(matches, predicate);
+ }
+
+ protected Predicate<Match> hasFeatureValue(final String featureName, final Object value) {
+ Predicate<Match> predicate = new Predicate<Match>() {
+ public boolean apply(Match match) {
+ final boolean ret;
+ final EObject left = match.getLeft();
+ final EObject right = match.getRight();
+ final EObject origin = match.getOrigin();
+ if (left != null) {
+ ret = Objects.equal(value, eGet(left, featureName));
+ } else if (right != null) {
+ ret = Objects.equal(value, eGet(right, featureName));
+ } else if (origin != null) {
+ ret = Objects.equal(value, eGet(origin, featureName));
+ } else {
+ ret = false;
+ }
+ return ret;
+ }
+ };
+ return predicate;
+ }
+
+ protected Object eGet(EObject eObject, String featureName) {
+ EStructuralFeature eStructuralFeature = eObject.eClass().getEStructuralFeature(featureName);
+ return eObject.eGet(eStructuralFeature);
+ }
+
+ protected List<Notifier> eAllChildren(Notifier notifier) {
+ List<Notifier> ret = newArrayList();
+ ITreeItemContentProvider contentProvider = adaptAsITreItemContentProvider(notifier);
+ Iterable<Notifier> children = filter(contentProvider.getChildren(notifier), Notifier.class);
+ for (Notifier child : children) {
+ ret.add(child);
+ ret.addAll(eAllChildren(child));
+ }
+ return ret;
+ }
+
+ protected ITreeItemContentProvider adaptAsITreItemContentProvider(Notifier notifier) {
+ ITreeItemContentProvider contentProvider = (ITreeItemContentProvider)compareItemProviderAdapterFactory
+ .adapt(notifier, ITreeItemContentProvider.class);
+ return contentProvider;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestMatchItemProviderSpec.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestMatchItemProviderSpec.java
index 3f9507a72..d351bcf21 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestMatchItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestMatchItemProviderSpec.java
@@ -1,145 +1,145 @@
-/*******************************************************************************
- * Copyright (c) 2012 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.tests.edit;
-
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.size;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.compare.Comparison;
-import org.eclipse.emf.compare.Diff;
-import org.eclipse.emf.compare.Match;
-import org.eclipse.emf.compare.provider.MatchItemProvider;
-import org.eclipse.emf.compare.provider.spec.MatchItemProviderSpec;
-import org.eclipse.emf.compare.tests.edit.data.ecore.a1.EcoreA1InputData;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
- */
-public class TestMatchItemProviderSpec extends AbstractTestCompareItemProviderAdapter {
-
- private MatchItemProvider itemProvider;
-
- @Override
- @Before
- public void before() throws IOException {
- super.before();
- itemProvider = (MatchItemProviderSpec)compareItemProviderAdapterFactory.createMatchAdapter();
- }
-
- @Test
- public void testGetChildren_EcoreA1() throws IOException {
- Match ePackageMatch = getEcoreA1_EPackageMatch();
-
- Collection<?> ePackageMatchChildren = itemProvider.getChildren(ePackageMatch);
- assertEquals(9, ePackageMatchChildren.size());
- assertEquals(4, size(filter(ePackageMatchChildren, Diff.class)));
- assertEquals(5, size(filter(ePackageMatchChildren, Match.class)));
- }
-
- static Match getEcoreA1_EPackageMatch() throws IOException {
- Comparison comparison = getComparison(new EcoreA1InputData());
-
- List<Match> matches = comparison.getMatches();
- Match ePackageMatch = matches.get(0);
- return ePackageMatch;
- }
-
- @Test
- public void testGetChildren_AudioVisualItem() throws IOException {
- Match ePackageMatch = getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
- Match audioVisualItem_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name",
- "AudioVisualItem");
- Collection<?> audioVisualItem_MatchChildren = itemProvider.getChildren(audioVisualItem_Match);
-
- assertEquals(3, audioVisualItem_MatchChildren.size());
- assertEquals(2, size(filter(audioVisualItem_MatchChildren, Diff.class)));
- assertEquals(1, size(filter(audioVisualItem_MatchChildren, Match.class)));
- }
-
- @Test
- public void testGetChildren_AudioVisualItem_lenght() throws IOException {
- Match ePackageMatch = getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
- Match audioVisualItem_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name",
- "AudioVisualItem");
- Collection<?> audioVisualItem_MatchChildren = itemProvider.getChildren(audioVisualItem_Match);
- Match audioVisualItem_legnth_Match = getMatchWithFeatureValue(audioVisualItem_MatchChildren, "name",
- "length");
- Collection<?> audioVisualItem_legnth_MatchChildren = itemProvider
- .getChildren(audioVisualItem_legnth_Match);
-
- assertEquals(2, audioVisualItem_legnth_MatchChildren.size());
- assertEquals(2, size(filter(audioVisualItem_legnth_MatchChildren, Diff.class)));
- assertEquals(0, size(filter(audioVisualItem_legnth_MatchChildren, Match.class)));
- }
-
- @Test
- public void testGetChildren_Book() throws IOException {
- Match ePackageMatch = getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
- Match book_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Book");
- Collection<?> book_MatchChildren = itemProvider.getChildren(book_Match);
-
- assertEquals(3, book_MatchChildren.size());
- assertEquals(3, size(filter(book_MatchChildren, Diff.class)));
- assertEquals(0, size(filter(book_MatchChildren, Match.class)));
- }
-
- @Test
- public void testGetChildren_BookCategory() throws IOException {
- Match ePackageMatch = getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
- Match bookCategory_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "BookCategory");
- Collection<?> bookCategory_MatchChildren = itemProvider.getChildren(bookCategory_Match);
-
- assertEquals(4, bookCategory_MatchChildren.size());
- assertEquals(4, size(filter(bookCategory_MatchChildren, Diff.class)));
- assertEquals(0, size(filter(bookCategory_MatchChildren, Match.class)));
- }
-
- @Test
- public void testGetChildren_Borrowable() throws IOException {
- Match ePackageMatch = getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
- Match borrowable_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Borrowable");
- Collection<?> borrowable_MatchChildren = itemProvider.getChildren(borrowable_Match);
-
- assertEquals(1, borrowable_MatchChildren.size());
- assertEquals(1, size(filter(borrowable_MatchChildren, Diff.class)));
- assertEquals(0, size(filter(borrowable_MatchChildren, Match.class)));
- }
-
- @Test
- public void testGetChildren_Person() throws IOException {
- Match ePackageMatch = getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
- Match person_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Person");
- Collection<?> person_MatchChildren = itemProvider.getChildren(person_Match);
-
- assertEquals(3, person_MatchChildren.size());
- assertEquals(3, size(filter(person_MatchChildren, Diff.class)));
- assertEquals(0, size(filter(person_MatchChildren, Match.class)));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.edit;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.size;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.provider.MatchItemProvider;
+import org.eclipse.emf.compare.provider.spec.MatchItemProviderSpec;
+import org.eclipse.emf.compare.tests.edit.data.ecore.a1.EcoreA1InputData;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
+public class TestMatchItemProviderSpec extends AbstractTestCompareItemProviderAdapter {
+
+ private MatchItemProvider itemProvider;
+
+ @Override
+ @Before
+ public void before() throws IOException {
+ super.before();
+ itemProvider = (MatchItemProviderSpec)compareItemProviderAdapterFactory.createMatchAdapter();
+ }
+
+ @Test
+ public void testGetChildren_EcoreA1() throws IOException {
+ Match ePackageMatch = getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackageMatchChildren = itemProvider.getChildren(ePackageMatch);
+ assertEquals(18, ePackageMatchChildren.size());
+ assertEquals(4, size(filter(ePackageMatchChildren, Diff.class)));
+ assertEquals(14, size(filter(ePackageMatchChildren, Match.class)));
+ }
+
+ static Match getEcoreA1_EPackageMatch() throws IOException {
+ Comparison comparison = getComparison(new EcoreA1InputData());
+
+ List<Match> matches = comparison.getMatches();
+ Match ePackageMatch = matches.get(0);
+ return ePackageMatch;
+ }
+
+ @Test
+ public void testGetChildren_AudioVisualItem() throws IOException {
+ Match ePackageMatch = getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
+ Match audioVisualItem_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name",
+ "AudioVisualItem");
+ Collection<?> audioVisualItem_MatchChildren = itemProvider.getChildren(audioVisualItem_Match);
+
+ assertEquals(4, audioVisualItem_MatchChildren.size());
+ assertEquals(2, size(filter(audioVisualItem_MatchChildren, Diff.class)));
+ assertEquals(2, size(filter(audioVisualItem_MatchChildren, Match.class)));
+ }
+
+ @Test
+ public void testGetChildren_AudioVisualItem_lenght() throws IOException {
+ Match ePackageMatch = getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
+ Match audioVisualItem_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name",
+ "AudioVisualItem");
+ Collection<?> audioVisualItem_MatchChildren = itemProvider.getChildren(audioVisualItem_Match);
+ Match audioVisualItem_legnth_Match = getMatchWithFeatureValue(audioVisualItem_MatchChildren, "name",
+ "length");
+ Collection<?> audioVisualItem_legnth_MatchChildren = itemProvider
+ .getChildren(audioVisualItem_legnth_Match);
+
+ assertEquals(2, audioVisualItem_legnth_MatchChildren.size());
+ assertEquals(2, size(filter(audioVisualItem_legnth_MatchChildren, Diff.class)));
+ assertEquals(0, size(filter(audioVisualItem_legnth_MatchChildren, Match.class)));
+ }
+
+ @Test
+ public void testGetChildren_Book() throws IOException {
+ Match ePackageMatch = getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
+ Match book_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Book");
+ Collection<?> book_MatchChildren = itemProvider.getChildren(book_Match);
+
+ assertEquals(6, book_MatchChildren.size());
+ assertEquals(3, size(filter(book_MatchChildren, Diff.class)));
+ assertEquals(3, size(filter(book_MatchChildren, Match.class)));
+ }
+
+ @Test
+ public void testGetChildren_BookCategory() throws IOException {
+ Match ePackageMatch = getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
+ Match bookCategory_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "BookCategory");
+ Collection<?> bookCategory_MatchChildren = itemProvider.getChildren(bookCategory_Match);
+
+ assertEquals(7, bookCategory_MatchChildren.size());
+ assertEquals(4, size(filter(bookCategory_MatchChildren, Diff.class)));
+ assertEquals(3, size(filter(bookCategory_MatchChildren, Match.class)));
+ }
+
+ @Test
+ public void testGetChildren_Borrowable() throws IOException {
+ Match ePackageMatch = getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
+ Match borrowable_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Borrowable");
+ Collection<?> borrowable_MatchChildren = itemProvider.getChildren(borrowable_Match);
+
+ assertEquals(3, borrowable_MatchChildren.size());
+ assertEquals(1, size(filter(borrowable_MatchChildren, Diff.class)));
+ assertEquals(2, size(filter(borrowable_MatchChildren, Match.class)));
+ }
+
+ @Test
+ public void testGetChildren_Person() throws IOException {
+ Match ePackageMatch = getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = itemProvider.getChildren(ePackageMatch);
+ Match person_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Person");
+ Collection<?> person_MatchChildren = itemProvider.getChildren(person_Match);
+
+ assertEquals(3, person_MatchChildren.size());
+ assertEquals(3, size(filter(person_MatchChildren, Diff.class)));
+ assertEquals(0, size(filter(person_MatchChildren, Match.class)));
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestReferenceChangeItemProviderSpec.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestReferenceChangeItemProviderSpec.java
index 0cda3ecfe..d219ef857 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestReferenceChangeItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit/TestReferenceChangeItemProviderSpec.java
@@ -1,295 +1,295 @@
-/*******************************************************************************
- * Copyright (c) 2012 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.tests.edit;
-
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.get;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.compare.AttributeChange;
-import org.eclipse.emf.compare.Match;
-import org.eclipse.emf.compare.ReferenceChange;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.junit.Test;
-
-/**
- * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
- */
-public class TestReferenceChangeItemProviderSpec extends AbstractTestCompareItemProviderAdapter {
-
- @Test
- public void testGetChildren_AudioVisualItem() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
- Match audioVisualItem_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name",
- "AudioVisualItem");
- Collection<?> audioVisualItem_MatchChildren = adaptAsITreItemContentProvider(audioVisualItem_Match)
- .getChildren(audioVisualItem_Match);
-
- ReferenceChange titleReferenceChange = getReferenceChangeWithFeatureValue(
- audioVisualItem_MatchChildren, "name", "title");
-
- Collection<?> titleReferenceChange_Children = adaptAsITreItemContentProvider(titleReferenceChange)
- .getChildren(titleReferenceChange);
-
- assertEquals(1, titleReferenceChange_Children.size());
- Object child = get(titleReferenceChange_Children, 0);
- assertTrue(child instanceof ReferenceChange);
- assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, ((ReferenceChange)child).getReference());
-
- ReferenceChange titledItemReferenceChange = getReferenceChangeWithFeatureValue(
- audioVisualItem_MatchChildren, "name", "TitledItem");
- Collection<?> titledItemReferenceChange_Children = adaptAsITreItemContentProvider(
- titledItemReferenceChange).getChildren(titledItemReferenceChange);
- assertEquals(0, titledItemReferenceChange_Children.size());
- }
-
- @Test
- public void testGetChildren_Book() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
- Match book_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Book");
- Collection<?> book_MatchChildren = adaptAsITreItemContentProvider(book_Match).getChildren(book_Match);
-
- ReferenceChange subtitleReferenceChange = getReferenceChangeWithFeatureValue(book_MatchChildren,
- "name", "subtitle");
-
- Collection<?> subtitleReferenceChange_Children = adaptAsITreItemContentProvider(
- subtitleReferenceChange).getChildren(subtitleReferenceChange);
-
- assertEquals(1, subtitleReferenceChange_Children.size());
- Notifier child = (Notifier)get(subtitleReferenceChange_Children, 0);
- assertTrue(child instanceof ReferenceChange);
- assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, ((ReferenceChange)child).getReference());
- assertTrue(adaptAsITreItemContentProvider(child).getChildren(child).isEmpty());
-
- ReferenceChange titleReferenceChange = getReferenceChangeWithFeatureValue(book_MatchChildren, "name",
- "title");
- Collection<?> titleReferenceChange_Children = adaptAsITreItemContentProvider(titleReferenceChange)
- .getChildren(titleReferenceChange);
- assertEquals(1, titleReferenceChange_Children.size());
- child = (Notifier)get(titleReferenceChange_Children, 0);
- assertTrue(child instanceof ReferenceChange);
- assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, ((ReferenceChange)child).getReference());
- assertTrue(adaptAsITreItemContentProvider(child).getChildren(child).isEmpty());
-
- ReferenceChange titledItemReferenceChange = getReferenceChangeWithFeatureValue(book_MatchChildren,
- "name", "TitledItem");
- Collection<?> titledItemReferenceChange_Children = adaptAsITreItemContentProvider(
- titledItemReferenceChange).getChildren(titledItemReferenceChange);
- assertEquals(0, titledItemReferenceChange_Children.size());
- }
-
- @Test
- public void testGetChildren_Borrowable() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
- Match borrowableCategory_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name",
- "Borrowable");
- Collection<?> borrowable_MatchChildren = adaptAsITreItemContentProvider(borrowableCategory_Match)
- .getChildren(borrowableCategory_Match);
-
- assertEquals(1, borrowable_MatchChildren.size());
- }
-
- @Test
- public void testGetChildren_BookCategory() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
- Match bookCategory_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "BookCategory");
- Collection<?> bookCategory_MatchChildren = adaptAsITreItemContentProvider(bookCategory_Match)
- .getChildren(bookCategory_Match);
-
- ReferenceChange dictionaryReferenceChange = getReferenceChangeWithFeatureValue(
- bookCategory_MatchChildren, "name", "Dictionary");
- ReferenceChange encyclopediaReferenceChange = getReferenceChangeWithFeatureValue(
- bookCategory_MatchChildren, "name", "Encyclopedia");
- ReferenceChange mangaReferenceChange = getReferenceChangeWithFeatureValue(bookCategory_MatchChildren,
- "name", "Manga");
- ReferenceChange manhwaReferenceChange = getReferenceChangeWithFeatureValue(
- bookCategory_MatchChildren, "name", "Manhwa");
-
- assertTrue(adaptAsITreItemContentProvider(dictionaryReferenceChange).getChildren(
- dictionaryReferenceChange).isEmpty());
- assertTrue(adaptAsITreItemContentProvider(encyclopediaReferenceChange).getChildren(
- encyclopediaReferenceChange).isEmpty());
- assertTrue(adaptAsITreItemContentProvider(mangaReferenceChange).getChildren(mangaReferenceChange)
- .isEmpty());
- assertTrue(adaptAsITreItemContentProvider(manhwaReferenceChange).getChildren(manhwaReferenceChange)
- .isEmpty());
- }
-
- @Test
- public void testGetChildren_Magazine1() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
-
- Collection<?> magazineChildren = null;
- for (ReferenceChange referenceChange : filter(ePackage_MatchChildren, ReferenceChange.class)) {
- EClass eClass = (EClass)referenceChange.getValue();
- if ("Magazine".equals(eClass.getName())
- && "CirculatingItem".equals(eClass.getESuperTypes().get(0).getName())) {
- magazineChildren = adaptAsITreItemContentProvider(referenceChange).getChildren(
- referenceChange);
- assertEquals(3, magazineChildren.size());
- break;
- }
- }
- ReferenceChange magazineSuperTypeChange = getReferenceChangeWithFeatureValue(magazineChildren,
- "name", "CirculatingItem");
- assertTrue(adaptAsITreItemContentProvider(magazineSuperTypeChange).getChildren(
- magazineSuperTypeChange).isEmpty());
-
- ReferenceChange magazineSFChange1 = getReferenceChangeWithFeatureValue(magazineChildren, "name",
- "pages");
- assertEquals(1, adaptAsITreItemContentProvider(magazineSFChange1).getChildren(magazineSFChange1)
- .size());
-
- ReferenceChange magazineSFChange2 = getReferenceChangeWithFeatureValue(magazineChildren, "name",
- "title");
- assertEquals(1, adaptAsITreItemContentProvider(magazineSFChange2).getChildren(magazineSFChange2)
- .size());
- }
-
- @Test
- public void testGetChildren_Magazine2() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
-
- Collection<?> magazineChildren = null;
- for (ReferenceChange referenceChange : filter(ePackage_MatchChildren, ReferenceChange.class)) {
- EClass eClass = (EClass)referenceChange.getValue();
- if ("Magazine".equals(eClass.getName())
- && "Periodical".equals(eClass.getESuperTypes().get(0).getName())) {
- magazineChildren = adaptAsITreItemContentProvider(referenceChange).getChildren(
- referenceChange);
- assertEquals(1, magazineChildren.size());
- break;
- }
- }
- ReferenceChange magazineSuperTypeChange = getReferenceChangeWithFeatureValue(magazineChildren,
- "name", "Periodical");
- assertTrue(adaptAsITreItemContentProvider(magazineSuperTypeChange).getChildren(
- magazineSuperTypeChange).isEmpty());
- }
-
- @Test
- public void testGetChildren_Periodical() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
- ReferenceChange periodical_ReferenceChange = getReferenceChangeWithFeatureValue(
- ePackage_MatchChildren, "name", "Periodical");
- Collection<?> periodical_ReferenceChangeChildren = adaptAsITreItemContentProvider(
- periodical_ReferenceChange).getChildren(periodical_ReferenceChange);
-
- assertEquals(3, periodical_ReferenceChangeChildren.size());
-
- ReferenceChange issuesPerYearChange = getReferenceChangeWithFeatureValue(
- periodical_ReferenceChangeChildren, "name", "issuesPerYear");
-
- ReferenceChange itemChange = getReferenceChangeWithFeatureValue(periodical_ReferenceChangeChildren,
- "name", "Item");
- ReferenceChange titledItemChange = getReferenceChangeWithFeatureValue(
- periodical_ReferenceChangeChildren, "name", "TitledItem");
-
- Collection<?> issuesPerYearChildren = adaptAsITreItemContentProvider(issuesPerYearChange)
- .getChildren(issuesPerYearChange);
- assertEquals(1, issuesPerYearChildren.size());
- ReferenceChange issuePerYearChild = (ReferenceChange)issuesPerYearChildren.iterator().next();
- assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, issuePerYearChild.getReference());
-
- assertTrue(adaptAsITreItemContentProvider(itemChange).getChildren(itemChange).isEmpty());
- assertTrue(adaptAsITreItemContentProvider(titledItemChange).getChildren(titledItemChange).isEmpty());
- }
-
- @Test
- public void testGetChildren_Person() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
- Match person_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Person");
- Collection<?> person_MatchChildren = adaptAsITreItemContentProvider(person_Match).getChildren(
- person_Match);
-
- assertEquals(3, person_MatchChildren.size());
-
- ReferenceChange issuesPerYearChange = getReferenceChangeWithFeatureValue(person_MatchChildren,
- "name", "firstName");
- Collection<?> firstNameChildren = adaptAsITreItemContentProvider(issuesPerYearChange).getChildren(
- issuesPerYearChange);
- assertEquals(1, firstNameChildren.size());
- ReferenceChange firstNameChild = (ReferenceChange)firstNameChildren.iterator().next();
- assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, firstNameChild.getReference());
-
- ReferenceChange fullNameChange = getReferenceChangeWithFeatureValue(person_MatchChildren, "name",
- "fullName");
- Collection<?> fullNameChildren = adaptAsITreItemContentProvider(fullNameChange).getChildren(
- fullNameChange);
- assertEquals(1, fullNameChildren.size());
- ReferenceChange fullNameChild = (ReferenceChange)fullNameChildren.iterator().next();
- assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, fullNameChild.getReference());
-
- ReferenceChange lastNameChange = getReferenceChangeWithFeatureValue(person_MatchChildren, "name",
- "lastName");
- Collection<?> lastNameChildren = adaptAsITreItemContentProvider(lastNameChange).getChildren(
- lastNameChange);
- assertEquals(2, lastNameChildren.size());
- Iterator<?> lastNameiterator = lastNameChildren.iterator();
- ReferenceChange lastName1stChild = (ReferenceChange)lastNameiterator.next();
- AttributeChange lastName2ndChild = (AttributeChange)lastNameiterator.next();
- assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, lastName1stChild.getReference());
- assertEquals(EcorePackage.Literals.ENAMED_ELEMENT__NAME, lastName2ndChild.getAttribute());
- }
-
- @Test
- public void testGetChildren_TitledItem() throws IOException {
- Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
-
- Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
- ePackageMatch);
-
- ReferenceChange titledItem_ReferenceChange = getReferenceChangeWithFeatureValue(
- ePackage_MatchChildren, "name", "TitledItem");
- Collection<?> titledItem_ReferenceChangeChildren = adaptAsITreItemContentProvider(
- titledItem_ReferenceChange).getChildren(titledItem_ReferenceChange);
- assertEquals(1, titledItem_ReferenceChangeChildren.size());
-
- ReferenceChange title_Change = (ReferenceChange)titledItem_ReferenceChangeChildren.iterator().next();
- Collection<?> title_ChangeChildren = adaptAsITreItemContentProvider(title_Change).getChildren(
- title_Change);
- assertEquals(1, title_ChangeChildren.size());
-
- ReferenceChange eType_Change = (ReferenceChange)title_ChangeChildren.iterator().next();
- assertTrue(adaptAsITreItemContentProvider(eType_Change).getChildren(eType_Change).isEmpty());
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.edit;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.get;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.compare.AttributeChange;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
+public class TestReferenceChangeItemProviderSpec extends AbstractTestCompareItemProviderAdapter {
+
+ @Test
+ public void testGetChildren_AudioVisualItem() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+ Match audioVisualItem_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name",
+ "AudioVisualItem");
+ Collection<?> audioVisualItem_MatchChildren = adaptAsITreItemContentProvider(audioVisualItem_Match)
+ .getChildren(audioVisualItem_Match);
+
+ ReferenceChange titleReferenceChange = getReferenceChangeWithFeatureValue(
+ audioVisualItem_MatchChildren, "name", "title");
+
+ Collection<?> titleReferenceChange_Children = adaptAsITreItemContentProvider(titleReferenceChange)
+ .getChildren(titleReferenceChange);
+
+ assertEquals(1, titleReferenceChange_Children.size());
+ Object child = get(titleReferenceChange_Children, 0);
+ assertTrue(child instanceof ReferenceChange);
+ assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, ((ReferenceChange)child).getReference());
+
+ ReferenceChange titledItemReferenceChange = getReferenceChangeWithFeatureValue(
+ audioVisualItem_MatchChildren, "name", "TitledItem");
+ Collection<?> titledItemReferenceChange_Children = adaptAsITreItemContentProvider(
+ titledItemReferenceChange).getChildren(titledItemReferenceChange);
+ assertEquals(0, titledItemReferenceChange_Children.size());
+ }
+
+ @Test
+ public void testGetChildren_Book() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+ Match book_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Book");
+ Collection<?> book_MatchChildren = adaptAsITreItemContentProvider(book_Match).getChildren(book_Match);
+
+ ReferenceChange subtitleReferenceChange = getReferenceChangeWithFeatureValue(book_MatchChildren,
+ "name", "subtitle");
+
+ Collection<?> subtitleReferenceChange_Children = adaptAsITreItemContentProvider(
+ subtitleReferenceChange).getChildren(subtitleReferenceChange);
+
+ assertEquals(1, subtitleReferenceChange_Children.size());
+ Notifier child = (Notifier)get(subtitleReferenceChange_Children, 0);
+ assertTrue(child instanceof ReferenceChange);
+ assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, ((ReferenceChange)child).getReference());
+ assertTrue(adaptAsITreItemContentProvider(child).getChildren(child).isEmpty());
+
+ ReferenceChange titleReferenceChange = getReferenceChangeWithFeatureValue(book_MatchChildren, "name",
+ "title");
+ Collection<?> titleReferenceChange_Children = adaptAsITreItemContentProvider(titleReferenceChange)
+ .getChildren(titleReferenceChange);
+ assertEquals(1, titleReferenceChange_Children.size());
+ child = (Notifier)get(titleReferenceChange_Children, 0);
+ assertTrue(child instanceof ReferenceChange);
+ assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, ((ReferenceChange)child).getReference());
+ assertTrue(adaptAsITreItemContentProvider(child).getChildren(child).isEmpty());
+
+ ReferenceChange titledItemReferenceChange = getReferenceChangeWithFeatureValue(book_MatchChildren,
+ "name", "TitledItem");
+ Collection<?> titledItemReferenceChange_Children = adaptAsITreItemContentProvider(
+ titledItemReferenceChange).getChildren(titledItemReferenceChange);
+ assertEquals(0, titledItemReferenceChange_Children.size());
+ }
+
+ @Test
+ public void testGetChildren_Borrowable() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+ Match borrowableCategory_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name",
+ "Borrowable");
+ Collection<?> borrowable_MatchChildren = adaptAsITreItemContentProvider(borrowableCategory_Match)
+ .getChildren(borrowableCategory_Match);
+
+ assertEquals(3, borrowable_MatchChildren.size());
+ }
+
+ @Test
+ public void testGetChildren_BookCategory() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+ Match bookCategory_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "BookCategory");
+ Collection<?> bookCategory_MatchChildren = adaptAsITreItemContentProvider(bookCategory_Match)
+ .getChildren(bookCategory_Match);
+
+ ReferenceChange dictionaryReferenceChange = getReferenceChangeWithFeatureValue(
+ bookCategory_MatchChildren, "name", "Dictionary");
+ ReferenceChange encyclopediaReferenceChange = getReferenceChangeWithFeatureValue(
+ bookCategory_MatchChildren, "name", "Encyclopedia");
+ ReferenceChange mangaReferenceChange = getReferenceChangeWithFeatureValue(bookCategory_MatchChildren,
+ "name", "Manga");
+ ReferenceChange manhwaReferenceChange = getReferenceChangeWithFeatureValue(
+ bookCategory_MatchChildren, "name", "Manhwa");
+
+ assertTrue(adaptAsITreItemContentProvider(dictionaryReferenceChange).getChildren(
+ dictionaryReferenceChange).isEmpty());
+ assertTrue(adaptAsITreItemContentProvider(encyclopediaReferenceChange).getChildren(
+ encyclopediaReferenceChange).isEmpty());
+ assertTrue(adaptAsITreItemContentProvider(mangaReferenceChange).getChildren(mangaReferenceChange)
+ .isEmpty());
+ assertTrue(adaptAsITreItemContentProvider(manhwaReferenceChange).getChildren(manhwaReferenceChange)
+ .isEmpty());
+ }
+
+ @Test
+ public void testGetChildren_Magazine1() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+
+ Collection<?> magazineChildren = null;
+ for (ReferenceChange referenceChange : filter(ePackage_MatchChildren, ReferenceChange.class)) {
+ EClass eClass = (EClass)referenceChange.getValue();
+ if ("Magazine".equals(eClass.getName())
+ && "CirculatingItem".equals(eClass.getESuperTypes().get(0).getName())) {
+ magazineChildren = adaptAsITreItemContentProvider(referenceChange).getChildren(
+ referenceChange);
+ assertEquals(3, magazineChildren.size());
+ break;
+ }
+ }
+ ReferenceChange magazineSuperTypeChange = getReferenceChangeWithFeatureValue(magazineChildren,
+ "name", "CirculatingItem");
+ assertTrue(adaptAsITreItemContentProvider(magazineSuperTypeChange).getChildren(
+ magazineSuperTypeChange).isEmpty());
+
+ ReferenceChange magazineSFChange1 = getReferenceChangeWithFeatureValue(magazineChildren, "name",
+ "pages");
+ assertEquals(1, adaptAsITreItemContentProvider(magazineSFChange1).getChildren(magazineSFChange1)
+ .size());
+
+ ReferenceChange magazineSFChange2 = getReferenceChangeWithFeatureValue(magazineChildren, "name",
+ "title");
+ assertEquals(1, adaptAsITreItemContentProvider(magazineSFChange2).getChildren(magazineSFChange2)
+ .size());
+ }
+
+ @Test
+ public void testGetChildren_Magazine2() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+
+ Collection<?> magazineChildren = null;
+ for (ReferenceChange referenceChange : filter(ePackage_MatchChildren, ReferenceChange.class)) {
+ EClass eClass = (EClass)referenceChange.getValue();
+ if ("Magazine".equals(eClass.getName())
+ && "Periodical".equals(eClass.getESuperTypes().get(0).getName())) {
+ magazineChildren = adaptAsITreItemContentProvider(referenceChange).getChildren(
+ referenceChange);
+ assertEquals(1, magazineChildren.size());
+ break;
+ }
+ }
+ ReferenceChange magazineSuperTypeChange = getReferenceChangeWithFeatureValue(magazineChildren,
+ "name", "Periodical");
+ assertTrue(adaptAsITreItemContentProvider(magazineSuperTypeChange).getChildren(
+ magazineSuperTypeChange).isEmpty());
+ }
+
+ @Test
+ public void testGetChildren_Periodical() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+ ReferenceChange periodical_ReferenceChange = getReferenceChangeWithFeatureValue(
+ ePackage_MatchChildren, "name", "Periodical");
+ Collection<?> periodical_ReferenceChangeChildren = adaptAsITreItemContentProvider(
+ periodical_ReferenceChange).getChildren(periodical_ReferenceChange);
+
+ assertEquals(5, periodical_ReferenceChangeChildren.size());
+
+ ReferenceChange issuesPerYearChange = getReferenceChangeWithFeatureValue(
+ periodical_ReferenceChangeChildren, "name", "issuesPerYear");
+
+ ReferenceChange itemChange = getReferenceChangeWithFeatureValue(periodical_ReferenceChangeChildren,
+ "name", "Item");
+ ReferenceChange titledItemChange = getReferenceChangeWithFeatureValue(
+ periodical_ReferenceChangeChildren, "name", "TitledItem");
+
+ Collection<?> issuesPerYearChildren = adaptAsITreItemContentProvider(issuesPerYearChange)
+ .getChildren(issuesPerYearChange);
+ assertEquals(1, issuesPerYearChildren.size());
+ ReferenceChange issuePerYearChild = (ReferenceChange)issuesPerYearChildren.iterator().next();
+ assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, issuePerYearChild.getReference());
+
+ assertTrue(adaptAsITreItemContentProvider(itemChange).getChildren(itemChange).isEmpty());
+ assertTrue(adaptAsITreItemContentProvider(titledItemChange).getChildren(titledItemChange).isEmpty());
+ }
+
+ @Test
+ public void testGetChildren_Person() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+ Match person_Match = getMatchWithFeatureValue(ePackage_MatchChildren, "name", "Person");
+ Collection<?> person_MatchChildren = adaptAsITreItemContentProvider(person_Match).getChildren(
+ person_Match);
+
+ assertEquals(3, person_MatchChildren.size());
+
+ ReferenceChange issuesPerYearChange = getReferenceChangeWithFeatureValue(person_MatchChildren,
+ "name", "firstName");
+ Collection<?> firstNameChildren = adaptAsITreItemContentProvider(issuesPerYearChange).getChildren(
+ issuesPerYearChange);
+ assertEquals(1, firstNameChildren.size());
+ ReferenceChange firstNameChild = (ReferenceChange)firstNameChildren.iterator().next();
+ assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, firstNameChild.getReference());
+
+ ReferenceChange fullNameChange = getReferenceChangeWithFeatureValue(person_MatchChildren, "name",
+ "fullName");
+ Collection<?> fullNameChildren = adaptAsITreItemContentProvider(fullNameChange).getChildren(
+ fullNameChange);
+ assertEquals(1, fullNameChildren.size());
+ ReferenceChange fullNameChild = (ReferenceChange)fullNameChildren.iterator().next();
+ assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, fullNameChild.getReference());
+
+ ReferenceChange lastNameChange = getReferenceChangeWithFeatureValue(person_MatchChildren, "name",
+ "lastName");
+ Collection<?> lastNameChildren = adaptAsITreItemContentProvider(lastNameChange).getChildren(
+ lastNameChange);
+ assertEquals(2, lastNameChildren.size());
+ Iterator<?> lastNameiterator = lastNameChildren.iterator();
+ ReferenceChange lastName1stChild = (ReferenceChange)lastNameiterator.next();
+ AttributeChange lastName2ndChild = (AttributeChange)lastNameiterator.next();
+ assertEquals(EcorePackage.Literals.ETYPED_ELEMENT__ETYPE, lastName1stChild.getReference());
+ assertEquals(EcorePackage.Literals.ENAMED_ELEMENT__NAME, lastName2ndChild.getAttribute());
+ }
+
+ @Test
+ public void testGetChildren_TitledItem() throws IOException {
+ Match ePackageMatch = TestMatchItemProviderSpec.getEcoreA1_EPackageMatch();
+
+ Collection<?> ePackage_MatchChildren = adaptAsITreItemContentProvider(ePackageMatch).getChildren(
+ ePackageMatch);
+
+ ReferenceChange titledItem_ReferenceChange = getReferenceChangeWithFeatureValue(
+ ePackage_MatchChildren, "name", "TitledItem");
+ Collection<?> titledItem_ReferenceChangeChildren = adaptAsITreItemContentProvider(
+ titledItem_ReferenceChange).getChildren(titledItem_ReferenceChange);
+ assertEquals(1, titledItem_ReferenceChangeChildren.size());
+
+ ReferenceChange title_Change = (ReferenceChange)titledItem_ReferenceChangeChildren.iterator().next();
+ Collection<?> title_ChangeChildren = adaptAsITreItemContentProvider(title_Change).getChildren(
+ title_Change);
+ assertEquals(1, title_ChangeChildren.size());
+
+ ReferenceChange eType_Change = (ReferenceChange)title_ChangeChildren.iterator().next();
+ assertTrue(adaptAsITreItemContentProvider(eType_Change).getChildren(eType_Change).isEmpty());
+ }
+}

Back to the top