|
24 | 24 | import org.eclipse.emf.ecore.EClass; |
25 | 25 | import org.eclipse.emf.ecore.EClassifier; |
26 | 26 | import org.eclipse.emf.ecore.EDataType; |
| 27 | +import org.eclipse.emf.ecore.EGenericType; |
27 | 28 | import org.eclipse.emf.ecore.EPackage; |
28 | 29 | import org.eclipse.emf.ecore.EcoreFactory; |
29 | 30 | import org.eclipse.emf.ecore.EcorePackage; |
@@ -62,6 +63,7 @@ public class EMFCommandCodecTest { |
62 | 63 | private static final String N_A = "n/a"; |
63 | 64 | private static final String ATTRIBUTE = "attribute"; |
64 | 65 | private static final String REFERENCE = "reference"; |
| 66 | + private static final String MONO_CONTAINMENT = "monovalued containment reference"; |
65 | 67 | private static final String REFERENCE_MANY = "reference (many)"; |
66 | 68 | private static final String REFERENCE_BY_INDEX = "reference (by index)"; |
67 | 69 |
|
@@ -107,6 +109,7 @@ public static Iterable<Object[]> parameters() { |
107 | 109 | new Object[] { EMFCommandType.SET, ATTRIBUTE, createAttributeSetCommand(), |
108 | 110 | createAttributeSetModel() }, // |
109 | 111 | new Object[] { EMFCommandType.SET, REFERENCE, createReferenceSetCommand(), createReferenceSetModel() }, // |
| 112 | + new Object[] { EMFCommandType.SET, MONO_CONTAINMENT, createMonoContainmentSetCommand(), createMonoContainmentSetModel() }, // |
110 | 113 | new Object[] { EMFCommandType.ADD, ATTRIBUTE, createAttributeAddCommand(), createAttributeAddModel() }, // |
111 | 114 | new Object[] { EMFCommandType.ADD, REFERENCE, createReferenceAddCommand(), createReferenceAddModel() }, // |
112 | 115 | new Object[] { EMFCommandType.ADD, REFERENCE_MANY, createReferenceAddMultipleCommand(), |
@@ -175,6 +178,25 @@ static CCommand createReferenceSetModel() { |
175 | 178 | return result; |
176 | 179 | } |
177 | 180 |
|
| 181 | + static Command createMonoContainmentSetCommand() { |
| 182 | + EGenericType newGenericType = EcoreFactory.eINSTANCE.createEGenericType(); |
| 183 | + |
| 184 | + return SetCommand.create(domain, ((EClass)ePackage.getEClassifiers().get(0)).getEStructuralFeatures().get(0), EcorePackage.Literals.ETYPED_ELEMENT__EGENERIC_TYPE, newGenericType); |
| 185 | + } |
| 186 | + |
| 187 | + static CCommand createMonoContainmentSetModel() { |
| 188 | + EGenericType newGenericType = EcoreFactory.eINSTANCE.createEGenericType(); |
| 189 | + |
| 190 | + CCommand result = CCommandFactory.eINSTANCE.createCommand(); |
| 191 | + result.setType(EMFCommandType.SET); |
| 192 | + result.setOwner(((EClass)ePackage.getEClassifiers().get(0)).getEStructuralFeatures().get(0)); |
| 193 | + result.setFeature("eGenericType"); |
| 194 | + result.getObjectValues().add(newGenericType); |
| 195 | + result.getObjectsToAdd().add(newGenericType); |
| 196 | + result.getIndices().add(NO_INDEX); |
| 197 | + return result; |
| 198 | + } |
| 199 | + |
178 | 200 | static Command createAttributeAddCommand() { |
179 | 201 | return AddCommand.create(domain, commandFixture, CCommandPackage.Literals.COMMAND__DATA_VALUES, "Foo", 0); |
180 | 202 | } |
|
0 commit comments