Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2012-11-12 04:12:30 -0500
committerMikaël Barbero2012-11-12 10:06:05 -0500
commit19f3633b5e5be63c6edfcb284348287aac2bbf86 (patch)
treeacf7363205c2e4dd58729ca665aaf72ff2b9829b /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/edit
parente5df5e12a16e761cc4edda0baba8c5ead9977b96 (diff)
downloadorg.eclipse.emf.compare-19f3633b5e5be63c6edfcb284348287aac2bbf86.tar.gz
org.eclipse.emf.compare-19f3633b5e5be63c6edfcb284348287aac2bbf86.tar.xz
org.eclipse.emf.compare-19f3633b5e5be63c6edfcb284348287aac2bbf86.zip
add few more ItemProvider #getChildren tests
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/TestReferenceChangeItemProviderSpec.java95
1 files changed, 94 insertions, 1 deletions
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 23380eff7..0cda3ecfe 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
@@ -17,8 +17,10 @@ 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;
@@ -198,5 +200,96 @@ public class TestReferenceChangeItemProviderSpec extends AbstractTestCompareItem
magazineSuperTypeChange).isEmpty());
}
- // still to add: Periodical, Person, TitleItem
+ @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());
+ }
}

Back to the top