/******************************************************************************* * Copyright (c) 2010, 2015 Willink Transformations 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: * E.D.Willink - initial API and implementation *******************************************************************************/ package org.eclipse.ocl.examples.test.xtext; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.StringWriter; import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EModelElement; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.URIConverter; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.ocl.common.internal.options.CommonOptions; import org.eclipse.ocl.examples.xtext.tests.TestUtil; import org.eclipse.ocl.examples.xtext.tests.XtextTestCase; import org.eclipse.ocl.pivot.SequenceType; import org.eclipse.ocl.pivot.Type; import org.eclipse.ocl.pivot.internal.complete.CompleteClassInternal; import org.eclipse.ocl.pivot.internal.complete.CompleteModelInternal; import org.eclipse.ocl.pivot.internal.context.ModelContext; import org.eclipse.ocl.pivot.internal.ecore.es2as.Ecore2AS; import org.eclipse.ocl.pivot.internal.manager.MetamodelManagerInternal; import org.eclipse.ocl.pivot.internal.messages.PivotMessagesInternal; import org.eclipse.ocl.pivot.internal.utilities.OCLInternal; import org.eclipse.ocl.pivot.internal.utilities.PivotConstantsInternal; import org.eclipse.ocl.pivot.internal.values.CollectionTypeParametersImpl; import org.eclipse.ocl.pivot.library.LibraryConstants; import org.eclipse.ocl.pivot.resource.ASResource; import org.eclipse.ocl.pivot.resource.CSResource; import org.eclipse.ocl.pivot.resource.ProjectManager; import org.eclipse.ocl.pivot.uml.UMLStandaloneSetup; import org.eclipse.ocl.pivot.utilities.ClassUtil; import org.eclipse.ocl.pivot.utilities.OCL; import org.eclipse.ocl.pivot.utilities.PivotConstants; import org.eclipse.ocl.pivot.utilities.StringUtil; import org.eclipse.ocl.pivot.values.CollectionTypeParameters; import org.eclipse.ocl.xtext.base.services.BaseLinkingService; import org.eclipse.ocl.xtext.base.utilities.BaseCSResource; import org.eclipse.ocl.xtext.essentialocl.utilities.EssentialOCLCSResource; import org.eclipse.ocl.xtext.oclinecorecs.OCLinEcoreCSPackage; import org.eclipse.xtext.resource.impl.ListBasedDiagnosticConsumer; import org.junit.Before; /** * Tests that load a model and verify that there are no unresolved proxies as a result. */ public class EditTests extends XtextTestCase { public class DebugRef { public final Object object; DebugRef(Object object) { this.object = object; } } @Override @Before public void setUp() throws Exception { TestUtil.doCompleteOCLSetup(); TestUtil.doOCLstdlibSetup(); super.setUp(); } private void assertHasComments(@NonNull Resource aResource, @NonNull String @NonNull [] comments) { Map<String, Integer> expected = new HashMap<String, Integer>(); for (String comment : comments) { Integer count = expected.get(comment); count = (count != null) ? (count + 1) : 1; expected.put(comment, count); } for (TreeIterator<EObject> tit = aResource.getAllContents(); tit.hasNext(); ) { EObject eObject = tit.next(); if (eObject instanceof EModelElement) { EAnnotation eAnnotation = ((EModelElement)eObject).getEAnnotation(PivotConstantsInternal.DOCUMENTATION_ANNOTATION_SOURCE); if (eAnnotation != null) { String comment = eAnnotation.getDetails().get(PivotConstantsInternal.DOCUMENTATION_ANNOTATION_KEY); Integer count = expected.get(comment); assertTrue("Expected comment '" + comment + "' exists", (count != null) && (count > 0)); expected.put(comment, (count != null ? count : 0) -1); } } } for (String comment : comments) { Integer occurences = expected.get(comment); assert occurences != null; assertEquals("Expected comment '" + comment + "' extra occurences", 0, occurences.intValue()); } } public boolean debugStateRef(WeakReference<Type> sequenceMyType) { DebugRef debugRef = new DebugRef(sequenceMyType.get()); return debugRef.object == null; } protected @NonNull Resource doRename(@NonNull OCL ocl, @NonNull CSResource xtextResource, @NonNull Resource asResource, String oldString, String newString, String... expectedErrors) throws IOException { String contextMessage = "Renaming '" + oldString + "' to '" + newString + "'"; // System.out.println("-----------------" + contextMessage + "----------------"); replace(xtextResource, oldString, newString); assertResourceErrors(contextMessage, xtextResource, expectedErrors); assertNoResourceErrors(contextMessage, asResource); boolean validSave = expectedErrors.length == 0; if (validSave) { assertNoValidationErrors(contextMessage, asResource); } Resource ecoreResource = as2ecore(ocl, asResource, null, true); assertNoResourceErrors(contextMessage, ecoreResource); return ecoreResource; } protected @NonNull Resource getEcoreFromCS(@NonNull OCL ocl, @NonNull String testDocument, @NonNull URI ecoreURI) throws IOException { @NonNull URI xtextURI = URI.createURI("test.oclinecore"); CSResource xtextResource = ocl.getCSResource(xtextURI, testDocument); assertNoResourceErrors("Loading Xtext", xtextResource); Resource asResource = cs2as(ocl, xtextResource, null); Resource ecoreResource = as2ecore(ocl, asResource, ecoreURI, true); return ecoreResource; } protected void replace(@NonNull CSResource xtextResource, String oldString, String newString) { String xtextContent = xtextResource.getContents().get(0).toString(); int index = xtextContent.indexOf(oldString); assert index >= 0; xtextResource.update(index, oldString.length(), newString); } public void testEdit_Paste_NsURI() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); CommonOptions.DEFAULT_DELEGATION_MODE.setDefaultValue(PivotConstants.OCL_DELEGATE_URI_PIVOT); String testDocument = "package example : ex = 'http://www.example.org/examples/example.ecore'\n" + "{\n" + " class Example\n" + " {\n" + " attribute name : String[?];\n" + " property children : Example[*] { ordered composes };\n" + " }\n" + "}\n"; CSResource xtextResource; Resource asResource; { URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.oclinecore"); xtextResource = ocl.getCSResource(outputURI, testDocument); asResource = cs2as(ocl, xtextResource, null); @SuppressWarnings("unused") Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); } // // Change NsURI. // { replace(xtextResource, "http://www.example.org/examples/example.ecore", "http://www.example.org/examples/example1.ecore"); assertNoResourceErrors("Pasting operation", xtextResource); assertNoValidationErrors("Pasting operation", xtextResource); assertNoResourceErrors("Pasting operation", asResource); assertNoValidationErrors("Pasting operation", asResource); URI ecoreURI2 = getProjectFileURI("test2.ecore"); @SuppressWarnings("unused") Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, false); } // // Revert NsURI. // { replace(xtextResource, "http://www.example.org/examples/example1.ecore", "http://www.example.org/examples/example.ecore"); assertNoResourceErrors("Unpasting operation", xtextResource); assertNoValidationErrors("Unpasting operation", xtextResource); assertNoResourceErrors("Unpasting operation", asResource); assertNoValidationErrors("Unpasting operation", asResource); URI ecoreURI3 = getProjectFileURI("test3.ecore"); @SuppressWarnings("unused") Resource ecoreResource3 = as2ecore(ocl, asResource, ecoreURI3, true); } ocl.dispose(); } public void testEdit_Paste_OCLinEcore() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); CommonOptions.DEFAULT_DELEGATION_MODE.setDefaultValue(PivotConstants.OCL_DELEGATE_URI_PIVOT); String oldDocument = "package example : ex = 'http://www.example.org/examples/example.ecore'\n" + "{\n" + " class Example\n" + " {\n" + " attribute name : String[?];\n" + " property children : Example[*] { ordered composes };\n" + " }\n" + "}\n"; String newDocument = "import ecore : 'http://www.eclipse.org/emf/2002/Ecore#/';\n" + "\n" + "package tutorial : tut = 'http://www.eclipse.org/mdt/ocl/oclinecore/tutorial'\n" + "{\n" + " class Library\n" + " {\n" + " attribute name : String;\n" + " property loans : Loan[*] { composes };\n" + " }\n" + " \n" + " class Loan\n" + " {\n" + " }\n" + "}\n"; CSResource xtextResource; Resource asResource; { URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.oclinecore"); xtextResource = ocl.getCSResource(outputURI, oldDocument); asResource = cs2as(ocl, xtextResource, null); @SuppressWarnings("unused") Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); } // // Change NsURI. // { replace(xtextResource, oldDocument.trim(), newDocument.trim()); assertNoResourceErrors("Pasting operation", xtextResource); assertNoValidationErrors("Pasting operation", xtextResource); assertNoResourceErrors("Pasting operation", asResource); assertNoValidationErrors("Pasting operation", asResource); URI ecoreURI2 = getProjectFileURI("test2.ecore"); @SuppressWarnings("unused") Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, false); } // // Revert NsURI. // { replace(xtextResource, newDocument.trim(), oldDocument.trim()); assertNoResourceErrors("Unpasting operation", xtextResource); assertNoValidationErrors("Unpasting operation", xtextResource); assertNoResourceErrors("Unpasting operation", asResource); assertNoValidationErrors("Unpasting operation", asResource); URI ecoreURI3 = getProjectFileURI("test3.ecore"); @SuppressWarnings("unused") Resource ecoreResource3 = as2ecore(ocl, asResource, ecoreURI3, true); } ocl.dispose(); } public void testEdit_Paste_operation_394057() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); // OCLDelegateDomain.initialize(null); // OCLDelegateDomain.initialize(null, OCLConstants.OCL_DELEGATE_URI); CommonOptions.DEFAULT_DELEGATION_MODE.setDefaultValue(PivotConstants.OCL_DELEGATE_URI_PIVOT); String testDocument = "package tutorial : tuttut = 'http://www.eclipse.org/mdt/ocl/oclinecore/tutorial'\n" + "{\n" + " class Library\n" + " {\n" + " property books#library : Book[*] { composes };\n" + " /*$$*/\n" + " }\n" + " class Book\n" + " {\n" + " attribute name : String;\n" + " property library#books : Library[?];\n" + " }\n" + "}\n"; String pasteText = "operation packageLabels(packages : Book[*] { !unique, ordered }) : String\n" + "{\n" + " body: packages?->sortedBy(name)?->iterate(p; acc : String = '' | acc + ' ' + p.name);\n" + // FIXME should not need second ?-> "}"; CSResource xtextResource; Resource asResource; { URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.oclinecore"); xtextResource = ocl.getCSResource(outputURI, testDocument); asResource = cs2as(ocl, xtextResource, null); @SuppressWarnings("unused") Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); } // // Change "/*$$*/" to "pasteText". // { replace(xtextResource, "/*$$*/", pasteText); assertNoResourceErrors("Pasting operation", xtextResource); assertNoValidationErrors("Pasting operation", xtextResource); assertNoResourceErrors("Pasting operation", asResource); assertNoValidationErrors("Pasting operation", asResource); URI ecoreURI2 = getProjectFileURI("test2.ecore"); @SuppressWarnings("unused") Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, false); } // // Change "pasteText" back to "/*$$*/". // { replace(xtextResource, pasteText, "/*$$*/"); assertNoResourceErrors("Unpasting operation", xtextResource); assertNoValidationErrors("Unpasting operation", xtextResource); assertNoResourceErrors("Unpasting operation", asResource); assertNoValidationErrors("Unpasting operation", asResource); URI ecoreURI3 = getProjectFileURI("test3.ecore"); @SuppressWarnings("unused") Resource ecoreResource3 = as2ecore(ocl, asResource, ecoreURI3, true); } ocl.dispose(); } public void testEdit_Paste_473249() throws Exception { BaseLinkingService.DEBUG_RETRY.setState(true); UMLStandaloneSetup.init(); OCL ocl = OCL.newInstance(getProjectMap()); // OCLDelegateDomain.initialize(null); // OCLDelegateDomain.initialize(null, OCLConstants.OCL_DELEGATE_URI); CommonOptions.DEFAULT_DELEGATION_MODE.setDefaultValue(PivotConstants.OCL_DELEGATE_URI_PIVOT); String testDocument = "import ecore : 'http://www.eclipse.org/emf/2002/Ecore' ; import uml : 'http://www.eclipse.org/uml2/5.0.0/UML' ;\n" + "\n" + "package UML2EcoreMapping : u2e = 'http://www.eclipse.org/ocl/2012/UML2EcoreMapping'\n" + "{\n" + " class CreateOperation extends OperationMapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: nameLabel(newName) + ' <= ' + 'operationLabels(oldOperations)';\n" + " }\n" + " attribute newName : String[1];\n" + " }\n" + " class CreatePackage extends PackageMapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: nameLabel(newName) + ' <= ' + packageLabels(oldPackages);\n" + " }\n" + " attribute newName : String[1];\n" + " attribute nsPrefix : String[1];\n" + " attribute nsURI : String[1];\n" + " attribute isASmetamodel : Boolean[1] = 'false';\n" + " attribute ecoreFileStem : String[?];\n" + " property typeMappings : TypeMapping[*] { ordered composes };\n" + " }\n" + " class CreateProperty extends PropertyMapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: nameLabel(newName) + ' <= ' + propertyLabels(oldProperties);\n" + " }\n" + " attribute newName : String[1];\n" + " attribute newIsDerived : ecore::EBooleanObject[?];\n" + " attribute newIsNullFree : ecore::EBooleanObject[?];\n" + " attribute newIsResolveProxies : ecore::EBooleanObject[?];\n" + " attribute newIsTransient : ecore::EBooleanObject[?];\n" + " attribute newIsUnsettable : ecore::EBooleanObject[?];\n" + " attribute newIsVolatile : ecore::EBooleanObject[?];\n" + " attribute newLowerBound : ecore::EIntegerObject[?];\n" + " property opposite : uml::Property[?];\n" + " }\n" + " class CreateType extends TypeMapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: nameLabel(newName) + ' <= ' + typeLabels(oldTypes);\n" + " }\n" + " attribute newName : String[1];\n" + " attribute newInstanceTypeName : String[?];\n" + " attribute newIsSerializable : ecore::EBooleanObject[?];\n" + " property orderedSuperTypes : uml::Type[*] { ordered };\n" + " property excludeProperties : uml::Property[*] { ordered };\n" + " property includeProperties : uml::Property[*] { ordered };\n" + " property excludeTypes : uml::Type[*] { ordered };\n" + " property operationMappings : OperationMapping[*] { ordered composes };\n" + " property propertyMappings : PropertyMapping[*] { ordered composes };\n" + " invariant UniqueCreatePropertyNames: propertyMappings->selectByKind(CreateProperty)->isUnique(newName);\n" + " }\n" + " class DeleteOperation extends OperationMapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: nameLabel(oldName) + ' <= ' + operationLabels(oldOperations);\n" + " }\n" + " attribute oldName : String[1];\n" + " }\n" + " class DeletePackage extends PackageMapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: oldName;\n" + " }\n" + " attribute oldName : String[1];\n" + " property deleteTypes : DeleteType[*] { ordered composes };\n" + " }\n" + " class DeleteProperty extends PropertyMapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: nameLabel(oldName) + ' <= ' + propertyLabels(oldProperties);\n" + " }\n" + " attribute oldName : String[1];\n" + " }\n" + " class DeleteType extends TypeMapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: nameLabel(oldName) + ' <= ' + typeLabels(oldTypes);\n" + " }\n" + " attribute oldName : String[1];\n" + " property operationMappings : OperationMapping[*] { ordered composes };\n" + " property propertyMappings : PropertyMapping[*] { ordered composes };\n" + " }\n" + " abstract class Mapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: 'default-label';\n" + " }\n" + " operation nameLabel(name : String[1]) : String[1]\n" + " {\n" + " body: if name = null then 'null' else name endif;\n" + " }\n" + " operation operationLabels(operations : uml::Operation[*] { ordered }) : String[1]\n" + " {\n" + " body: operations->sortedBy(nameLabel(name))->iterate(p; acc : String = '' | let type : uml::Type = if p.class <> null then p.class else p.interface endif in acc + ' ' + nameLabel(p.class.package.name) + '::' + nameLabel(p.class.name) + '::' + nameLabel(p.name));\n" + " }\n" + " operation packageLabel(p : uml::Package[1]) : String[1]\n" + " {\n" + " body: if p <> null then nameLabel(p.name) else 'null' endif;\n" + " }\n" + " operation packageLabels(packages : uml::Package[*] { ordered }) : String[1]\n" + " {\n" + " body: packages->sortedBy(nameLabel(name))->iterate(p; acc : String = '' | acc + ' ' + packageLabel(p));\n" + " }\n" + " operation propertyLabel(p : uml::Property[1]) : String[1]\n" + " {\n" + " body: if p <> null then let t = if p.class <> null then p.class else p.association endif in typeLabel(t) + '::' + nameLabel(p.name) else 'null' endif;\n" + " }\n" + " operation propertyLabels(properties : uml::Property[*] { ordered }) : String[1]\n" + " {\n" + " body: properties->sortedBy(nameLabel(name))->iterate(p; acc : String = '' | acc + ' ' + propertyLabel(p));\n" + " }\n" + " operation typeLabel(t : uml::Type[1]) : String[1]\n" + " {\n" + " body: if t <> null then packageLabel(t.package) + '::' + nameLabel(t.name) else 'null' endif;\n" + " }\n" + " operation typeLabels(types : uml::Type[*] { ordered }) : String[1]\n" + " {\n" + " body: types->sortedBy(nameLabel(name))->iterate(t; acc : String = '' | acc + ' ' + typeLabel(t));\n" + " }\n" + " attribute label : String[1] { transient }\n" + " {\n" + " initial: label();\n" + " }\n" + " }\n" + " class Mappings\n" + " {\n" + " property mappings : Mapping[*] { ordered composes };\n" + " }\n" + " abstract class PackageMapping extends Mapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: packageLabels(oldPackages);\n" + " }\n" + " property oldPackages : uml::Package[*] { ordered };\n" + " }\n" + " abstract class OperationMapping extends Mapping\n" + " {\n" + " property oldOperations : uml::Operation[*] { ordered };\n" + " }\n" + " abstract class PropertyMapping extends Mapping\n" + " {\n" + " property oldProperties : uml::Property[*] { ordered };\n" + " }\n" + " abstract class TypeMapping extends Mapping\n" + " {\n" + " operation label() : String[1]\n" + " {\n" + " body: typeLabels(oldTypes);\n" + " }\n" + " property oldTypes : uml::Type[*] { ordered };\n" + " }\n" + "}"; CSResource xtextResource; // System.out.println("------Load--------------------------------"); Resource asResource; { URI ecoreURI1 = getProjectFileURI("Bug473249a.ecore"); URI outputURI = getProjectFileURI("Bug473249.oclinecore"); xtextResource = ocl.getCSResource(outputURI, testDocument); // System.out.println("------cs2as--------------------------------"); asResource = cs2as(ocl, xtextResource, null); // System.out.println("------as2ecore--------------------------------"); @SuppressWarnings("unused") Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); } // // Change "/*$$*/" to "pasteText". // { // System.out.println("------replace--------------------------------"); replace(xtextResource, "'operationLabels(oldOperations)'", "operationLabels(oldOperations)"); assertNoResourceErrors("Pasting operation", xtextResource); // System.out.println("------validate--------------------------------"); assertNoValidationErrors("Pasting operation", xtextResource); assertNoResourceErrors("Pasting operation", asResource); assertNoValidationErrors("Pasting operation", asResource); URI ecoreURI2 = getProjectFileURI("Bug473249b.ecore"); // System.out.println("------as2ecore--------------------------------"); @SuppressWarnings("unused") Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, false); } ocl.dispose(); } public void testEdit_Reclass_ecore_383285() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); String testDocument_class = "package p1 : p2 = 'p3' {\n" + " class C : 'java.lang.Object';\n" + "}\n"; String testDocument_datatype = "package p1 : p2 = 'p3' {\n" + " datatype C : 'java.lang.Object';\n" + "}\n"; URI ecoreURI_class = getProjectFileURI("test-class.ecore"); URI ecoreURI_datatype = getProjectFileURI("test-datatype.ecore"); OCL ocl_class = OCL.newInstance(getProjectMap()); OCL ocl_datatype = OCL.newInstance(getProjectMap()); Resource ecoreResource_class = getEcoreFromCS(ocl_class, testDocument_class, ecoreURI_class); Resource ecoreResource_datatype = getEcoreFromCS(ocl_datatype, testDocument_datatype, ecoreURI_datatype); CSResource xtextResource; Resource asResource; { URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.oclinecore"); xtextResource = ocl.getCSResource(outputURI, testDocument_class); asResource = cs2as(ocl, xtextResource, null); Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); TestUtil.assertSameModel(ecoreResource_class, ecoreResource1); } // // Change "class" to "datatype" and see EClass change to EDataType. // { replace(xtextResource, "class", "datatype"); assertNoResourceErrors("Reclassing to datatype", xtextResource); URI ecoreURI2 = getProjectFileURI("test2.ecore"); Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, false); TestUtil.assertSameModel(ecoreResource_datatype, ecoreResource2); } // // Change "datatype" back to "class" and see EDataType change back to EClass. // { replace(xtextResource, "datatype", "class"); assertNoResourceErrors("Reclassing to class", xtextResource); URI ecoreURI3 = getProjectFileURI("test3.ecore"); Resource ecoreResource3 = as2ecore(ocl, asResource, ecoreURI3, true); TestUtil.assertSameModel(ecoreResource_class, ecoreResource3); } ocl_class.dispose(); ocl_datatype.dispose(); ocl.dispose(); } public void testEdit_Comments() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); String testDocument_uncommented = "package p1 : p2 = 'p3' {\n" + " class C : 'java.lang.Object';\n" + "}\n"; String testDocument_commented = "package p1 : p2 = 'p3' {\n" + " /* a comment */\n" + " class C : 'java.lang.Object';\n" + "}\n"; String testDocument_recommented = "package p1 : p2 = 'p3' {\n" + " /*\n" + " * yet \n" + " * another \n" + " * comment\n" + " */\n" + " class C : 'java.lang.Object';\n" + "}\n"; URI ecoreURI_uncommented = getProjectFileURI("test-uncommented.ecore"); URI ecoreURI_commented = getProjectFileURI("test-commented.ecore"); URI ecoreURI_recommented = getProjectFileURI("test-recommented.ecore"); OCL ocl_uncommented = OCL.newInstance(getProjectMap()); OCL ocl_commented = OCL.newInstance(getProjectMap()); OCL ocl_recommented = OCL.newInstance(getProjectMap()); Resource ecoreResource_uncommented = getEcoreFromCS(ocl_uncommented, testDocument_uncommented, ecoreURI_uncommented); Resource ecoreResource_commented = getEcoreFromCS(ocl_commented, testDocument_commented, ecoreURI_commented); Resource ecoreResource_recommented = getEcoreFromCS(ocl_recommented, testDocument_recommented, ecoreURI_recommented); assertHasComments(ecoreResource_uncommented, new @NonNull String @NonNull []{}); assertHasComments(ecoreResource_commented, new @NonNull String @NonNull []{"a comment"}); assertHasComments(ecoreResource_recommented, new @NonNull String @NonNull []{"yet\nanother\ncomment"}); CSResource xtextResource; Resource asResource; { URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.oclinecore"); xtextResource = ocl.getCSResource(outputURI, testDocument_uncommented); asResource = cs2as(ocl, xtextResource, null); Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); TestUtil.assertSameModel(ecoreResource_uncommented, ecoreResource1); } // // Change "class" to "/* a comment */class". // { replace(xtextResource, "class", "/* a comment */class"); assertNoResourceErrors("Adding comment", xtextResource); URI ecoreURI2 = getProjectFileURI("test2.ecore"); Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, false); TestUtil.assertSameModel(ecoreResource_commented, ecoreResource2); } // // Change "/* a comment */" to "/* yet\n* another\n * comment */". // { replace(xtextResource, "/* a comment */", "/* yet\n* another\n * comment */"); assertNoResourceErrors("Changing comment", xtextResource); URI ecoreURI3 = getProjectFileURI("test3.ecore"); Resource ecoreResource3 = as2ecore(ocl, asResource, ecoreURI3, true); TestUtil.assertSameModel(ecoreResource_recommented, ecoreResource3); } // // Change "/* yet\n* another\n * comment */" back to nothing. // { replace(xtextResource, "/* yet\n* another\n * comment */", ""); assertNoResourceErrors("Removing comment", xtextResource); URI ecoreURI4 = getProjectFileURI("test4.ecore"); Resource ecoreResource4 = as2ecore(ocl, asResource, ecoreURI4, true); TestUtil.assertSameModel(ecoreResource_uncommented, ecoreResource4); } ocl_uncommented.dispose(); ocl_commented.dispose(); ocl_recommented.dispose(); ocl.dispose(); } public void testEdit_Refresh_ecore_382230() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); // OCLDelegateDomain.initialize(null); // OCLDelegateDomain.initialize(null, OCLConstants.OCL_DELEGATE_URI); CommonOptions.DEFAULT_DELEGATION_MODE.setDefaultValue(PivotConstants.OCL_DELEGATE_URI_PIVOT); OCL ocl0 = OCL.newInstance(getProjectMap()); String testDocument = "package tutorial : tuttut = 'http://www.eclipse.org/mdt/ocl/oclinecore/tutorial'\n" + "{\n" + " class Library\n" + " {\n" + " property books#library : Book[*] { composes };\n" + " }\n" + " class Book\n" + " {\n" + " property library#books : Library[?];\n" + " property name : String;\n" + " invariant NameNotEmpty: name->notEmpty();\n" + " }\n" + "}\n"; URI ecoreURI = createEcoreFile(ocl0, "RefreshTest.ecore", testDocument, true); ocl0.dispose(); // // Load and instrument test document // OCLInternal ocl1 = OCLInternal.newInstance(getProjectMap(), null); Resource ecoreResource = ClassUtil.nonNullEMF(ocl1.getResourceSet().getResource(ecoreURI, true)); assertNoResourceErrors("Ecore load", ecoreResource); assertNoValidationErrors("Ecore load", ecoreResource); ASResource asResource = ocl1.ecore2as(ecoreResource); assertNoResourceErrors("Pivot load", asResource); assertNoValidationErrors("Pivot load", asResource); Set<EObject> loadPivotContent = new HashSet<EObject>(); for (TreeIterator<EObject> tit = asResource.getAllContents(); tit.hasNext(); ) { EObject eObject = tit.next(); // System.out.println(ClassUtil.debugSimpleName(eObject)); loadPivotContent.add(eObject); } { BaseCSResource xtextResource1 = (BaseCSResource) ocl1.getResourceSet().createResource(ecoreURI.appendFileExtension("oclinecore"), OCLinEcoreCSPackage.eCONTENT_TYPE); xtextResource1.setURI(ecoreURI); ocl1.as2cs(asResource, xtextResource1); assertNoResourceErrors("Xtext load", xtextResource1); assertNoValidationErrors("Xtext load", xtextResource1); ListBasedDiagnosticConsumer diagnosticsConsumer1 = new ListBasedDiagnosticConsumer(); xtextResource1.update(diagnosticsConsumer1); Set<EObject> parsePivotContent = new HashSet<EObject>(); for (TreeIterator<EObject> tit = asResource.getAllContents(); tit.hasNext(); ) { EObject eObject = tit.next(); // System.out.println(ClassUtil.debugSimpleName(eObject)); parsePivotContent.add(eObject); } assertEquals(loadPivotContent.size(), parsePivotContent.size()); assertEquals(loadPivotContent, parsePivotContent); } // // Reload and re-instrument test document // StringWriter writer = new StringWriter(); OutputStream outputStream = new URIConverter.WriteableOutputStream(writer, "UTF-8"); ecoreResource.save(outputStream, null); ecoreResource.unload(); InputStream inputStream = new URIConverter.ReadableInputStream(writer.toString().replace("tuttut", "tut"), "UTF-8"); ecoreResource.load(inputStream, null); assertNoResourceErrors("Ecore reload", ecoreResource); assertNoValidationErrors("Ecore reload", ecoreResource); Ecore2AS ecore2as = Ecore2AS.getAdapter(ecoreResource, ocl1.getEnvironmentFactory()); ecore2as.update(asResource, ClassUtil.nonNullEMF(ecoreResource.getContents())); assertNoResourceErrors("Pivot reload", ecoreResource); assertNoValidationErrors("Pivot reload", ecoreResource); Set<EObject> newPivotContent = new HashSet<EObject>(); for (TreeIterator<EObject> tit = asResource.getAllContents(); tit.hasNext(); ) { EObject eObject = tit.next(); // System.out.println(PivotUtil.debugSimpleName(eObject)); newPivotContent.add(eObject); } assertEquals(loadPivotContent.size(), newPivotContent.size()); assertEquals(loadPivotContent, newPivotContent); { BaseCSResource xtextResource2 = (BaseCSResource) ocl1.getResourceSet().createResource(ecoreURI.appendFileExtension("oclinecore"), OCLinEcoreCSPackage.eCONTENT_TYPE); xtextResource2.setURI(ecoreURI); ocl1.as2cs(asResource, xtextResource2); assertNoResourceErrors("Xtext load", xtextResource2); assertNoValidationErrors("Xtext load", xtextResource2); ListBasedDiagnosticConsumer diagnosticsConsumer2 = new ListBasedDiagnosticConsumer(); xtextResource2.update(diagnosticsConsumer2); Set<EObject> reparsePivotContent = new HashSet<EObject>(); for (TreeIterator<EObject> tit = asResource.getAllContents(); tit.hasNext(); ) { EObject eObject = tit.next(); // System.out.println(PivotUtil.debugSimpleName(eObject)); reparsePivotContent.add(eObject); } assertEquals(loadPivotContent.size(), reparsePivotContent.size()); assertEquals(loadPivotContent, reparsePivotContent); } ocl.dispose(); } public void testEdit_Rename_ecore() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); String testDocument = "module m1 \n" + "package p1 : p2 = 'p3' {\n" + "}\n"; URI ecoreURI0 = getProjectFileURI("test0.ecore"); OCL ocl1 = OCL.newInstance(getProjectMap()); Resource ecoreResource0 = getEcoreFromCS(ocl1, testDocument, ecoreURI0); CSResource xtextResource; Resource asResource; { URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.oclinecore"); xtextResource = ocl.getCSResource(outputURI, testDocument); asResource = cs2as(ocl, xtextResource, null); Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); TestUtil.assertSameModel(ecoreResource0, ecoreResource1); } // // Inserting a leading space has no Ecore effect. // { xtextResource.update(0, 0, " "); assertNoResourceErrors("Adding space", xtextResource); URI ecoreURI2 = getProjectFileURI("test2.ecore"); Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, true); TestUtil.assertSameModel(ecoreResource0, ecoreResource2); } // // Deleting the leading space has no Ecore effect. // { xtextResource.update(0, 1, ""); assertNoResourceErrors("Deleting space", xtextResource); URI ecoreURI3 = getProjectFileURI("test3.ecore"); Resource ecoreResource3 = as2ecore(ocl, asResource, ecoreURI3, true); TestUtil.assertSameModel(ecoreResource0, ecoreResource3); } // // Changing "p1" to "pkg" renames the package. // { replace(xtextResource, "p1", "pkg"); assertNoResourceErrors("Renaming", xtextResource); URI ecoreURI4 = getProjectFileURI("test4.ecore"); Resource ecoreResource4 = as2ecore(ocl, asResource, ecoreURI4, true); ((EPackage)ecoreResource0.getContents().get(0)).setName("pkg"); TestUtil.assertSameModel(ecoreResource0, ecoreResource4); } ocl1.dispose(); ocl.dispose(); } public void testEdit_Rename_Restore_ecore() throws Exception { OCLInternal ocl = OCLInternal.newInstance(getProjectMap(), null); String testDocument = "package TestPackage : tp = 'TestPackage'\n" + "{\n" + " class TestClass1 {\n" + " property testProperty1 : Integer;\n" + " operation testOperation(i : Integer) : Integer;\n" + " invariant testInvariant: 1 = 0;\n" + " }\n" + " class TestClass2 {\n" + " property testProperty2 : TestClass1[1];\n" + " property testProperty3 : Integer[*];\n" + " invariant testInvariant: testProperty2.testProperty1 = testProperty2.testOperation(123456);\n" + " }\n" + "}\n"; URI ecoreURI0 = getProjectFileURI("test0.ecore"); OCL ocl1 = OCL.newInstance(getProjectMap()); Resource ecoreResource0 = getEcoreFromCS(ocl1, testDocument, ecoreURI0); URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.oclinecore"); CSResource xtextResource = ClassUtil.nonNullState(ocl.getCSResource(outputURI, testDocument)); Resource asResource = cs2as(ocl, xtextResource, null); { Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); TestUtil.assertSameModel(ecoreResource0, ecoreResource1); } Type pivotTestClass1 = ClassUtil.nonNullState(ocl.getMetamodelManager().getPrimaryType("TestPackage", "TestClass1")); // // Changing "TestClass1" to "Testing" renames a type and breaks the invariant. // doRename(ocl, xtextResource, asResource, "TestClass1", "Testing", // ClassUtil.bind(OCLMessages.Unresolved_ERROR_, "Type", pivotTestClass1.getName()), StringUtil.bind(PivotMessagesInternal.UnresolvedType_ERROR_, "", pivotTestClass1.getName()), StringUtil.bind(PivotMessagesInternal.UnresolvedProperty_ERROR_, "OclInvalid", "testProperty1"), StringUtil.bind(PivotMessagesInternal.UnresolvedOperationCall_ERROR_, "OclInvalid", "testOperation", "123456")); // // Changing "Testing" back to "TestClass1" restores the type and the invariant. // TestUtil.assertSameModel(ecoreResource0, doRename(ocl, xtextResource, asResource, "Testing", "TestClass1")); pivotTestClass1 = ocl.getMetamodelManager().getPrimaryType("TestPackage", "TestClass1"); // // Changing "testProperty1" to "tProperty" renames the property and breaks the invariant. // doRename(ocl, xtextResource, asResource, "testProperty1", "tProperty", StringUtil.bind(PivotMessagesInternal.UnresolvedProperty_ERROR_, pivotTestClass1 + "", "testProperty1")); // // Changing "tProperty" back to "testProperty" restores the property and the invariant. // TestUtil.assertSameModel(ecoreResource0, doRename(ocl, xtextResource, asResource, "tProperty", "testProperty1")); // // Changing "testOperation" to "tOperation" renames the operation and breaks the invariant. // doRename(ocl, xtextResource, asResource, "testOperation", "tOperation", StringUtil.bind(PivotMessagesInternal.UnresolvedOperationCall_ERROR_, pivotTestClass1 + "", "testOperation", "123456")); // // Changing "tOperation" back to "testOperation" restores the operation and the invariant. // TestUtil.assertSameModel(ecoreResource0, doRename(ocl, xtextResource, asResource, "tOperation", "testOperation")); // // Changing "testOperation(i : Integer)" to "testOperation()" mismatches the operation signature and breaks the invariant. // doRename(ocl, xtextResource, asResource, "testOperation(i : Integer)", "testOperation()", StringUtil.bind(PivotMessagesInternal.UnresolvedOperationCall_ERROR_, pivotTestClass1 + "", "testOperation", "123456")); // // Changing "testOperation()" back to "testOperation(i : Integer)" restores the operation and the invariant. // TestUtil.assertSameModel(ecoreResource0, doRename(ocl, xtextResource, asResource, "testOperation()", "testOperation(i : Integer)")); // // Changing "testOperation(i : Integer)" to "testOperation(s : String)" mismatches the operation signature and breaks the invariant. // doRename(ocl, xtextResource, asResource, "testOperation(i : Integer)", "testOperation(s : String)", StringUtil.bind(PivotMessagesInternal.UnresolvedOperationCall_ERROR_, pivotTestClass1 + "", "testOperation", "Integer")); // // Changing "testOperation()" back to "testOperation(i : Integer)" restores the operation and the invariant. // TestUtil.assertSameModel(ecoreResource0, doRename(ocl, xtextResource, asResource, "testOperation(s : String)", "testOperation(i : Integer)")); // ocl1.dispose(); ocl.dispose(); } public void testEdit_StaleReference_ecore() throws Exception { OCLInternal ocl = OCLInternal.newInstance(getProjectMap(), null); String testDocument = "package TestPackage : tp = 'TestPackage'\n" + "{\n" + " class TestClass1 {\n" + " property testProperty1 : Integer;\n" + " operation testOperation() : Integer;\n" + " invariant testInvariant: 1 = 0;\n" + " }\n" + " class TestClass2 {\n" + " property testProperty2 : TestClass1[*];\n" + " invariant testInvariant: testProperty2?->select(testOperation() = testProperty1)->isEmpty();\n" + " }\n" + "}\n"; URI ecoreURI0 = getProjectFileURI("test0.ecore"); // System.out.println("*************load-reference*********************************************************"); OCL ocl1 = OCL.newInstance(getProjectMap()); Resource ecoreResource0 = getEcoreFromCS(ocl1, testDocument, ecoreURI0); URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.oclinecore"); CSResource xtextResource = ocl.getCSResource(outputURI, testDocument); Resource asResource = cs2as(ocl, xtextResource, null); { Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); TestUtil.assertSameModel(ecoreResource0, ecoreResource1); } Type pivotTestClass1 = ClassUtil.nonNullState(ocl.getMetamodelManager().getPrimaryType("TestPackage", "TestClass1")); // // Changing "TestClass1" to "Testing" renames a type and breaks the referredProperty/referredOperation. // doRename(ocl, xtextResource, asResource, "TestClass1", "Testing", StringUtil.bind(PivotMessagesInternal.UnresolvedType_ERROR_, "", pivotTestClass1.getName())); // // Changing "Testing" back to "TestClass1" restores the type and the referredProperty/referredOperation. // TestUtil.assertSameModel(ecoreResource0, doRename(ocl, xtextResource, asResource, "Testing", "TestClass1")); pivotTestClass1 = ClassUtil.nonNullState(ocl.getMetamodelManager().getPrimaryType("TestPackage", "TestClass1")); // // Changing "TestClass1" to "Testing" renames a type and breaks the referredProperty/referredOperation. // doRename(ocl, xtextResource, asResource, "TestClass1", "Testing", StringUtil.bind(PivotMessagesInternal.UnresolvedType_ERROR_, "", pivotTestClass1.getName())); // // Changing "Testing" back to "TestClass1" restores the type and the referredProperty/referredOperation. // TestUtil.assertSameModel(ecoreResource0, doRename(ocl, xtextResource, asResource, "Testing", "TestClass1")); pivotTestClass1 = ocl.getMetamodelManager().getPrimaryType("TestPackage", "TestClass1"); // ocl1.dispose(); ocl.dispose(); } public void testEdit_StaleSpecialization() throws Exception { OCLInternal ocl = OCLInternal.newInstance(getProjectMap(), null); String testDocument = "import '" + LibraryConstants.STDLIB_URI + "';\n" + "library ocl : ocl = '" + LibraryConstants.STDLIB_URI + "' {\n" + "type MyType conformsTo OclAny{\n" + "operation testFunction() : Boolean;\n" + "}\n" + "}\n"; URI outputURI = getProjectFileURI("test.oclstdlib"); MetamodelManagerInternal metamodelManager = ocl.getMetamodelManager(); CompleteModelInternal completeModel = metamodelManager.getCompleteModel(); ModelContext modelContext = new ModelContext(ocl.getEnvironmentFactory(), outputURI); EssentialOCLCSResource xtextResource = (EssentialOCLCSResource) modelContext.createBaseResource(testDocument); Resource asResource = cs2as(ocl, xtextResource, null); assertResourceErrors("Loading input", xtextResource); assertNoResourceErrors("Loading input", asResource); // Type myType = ClassUtil.nonNullState(metamodelManager.getPrimaryType(LibraryConstants.STDLIB_URI, "MyType")); SequenceType sequenceType = ocl.getStandardLibrary().getSequenceType(); CollectionTypeParameters<@NonNull Type> typeParameters = new CollectionTypeParametersImpl<@NonNull Type>(myType, false, null, null); CompleteClassInternal sequenceCompleteClass = metamodelManager.getCompleteClass(sequenceType); WeakReference<Type> sequenceMyType = new WeakReference<Type>(completeModel.findCollectionType(sequenceCompleteClass, typeParameters)); assertNull(sequenceMyType.get()); // doRename(ocl, xtextResource, asResource, "Boolean", "Sequence(MyType)"); sequenceMyType = new WeakReference<Type>(completeModel.findCollectionType(sequenceCompleteClass, typeParameters)); assertNotNull(sequenceMyType.get()); // doRename(ocl, xtextResource, asResource, "Sequence(MyType)", "Set(MyType)"); System.gc(); sequenceMyType = new WeakReference<Type>(completeModel.findCollectionType(sequenceCompleteClass, typeParameters)); boolean isNull = debugStateRef(sequenceMyType); sequenceMyType = null; assertTrue(isNull); ocl.dispose(); } public void testEdit_Paste_CompleteOCL() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); // OCLDelegateDomain.initialize(null); // OCLDelegateDomain.initialize(null, OCLConstants.OCL_DELEGATE_URI); CommonOptions.DEFAULT_DELEGATION_MODE.setDefaultValue(PivotConstants.OCL_DELEGATE_URI_PIVOT); String testDocument = "package ocl\n" + "context IterateExp\n" + "inv True: true\n" + "/*$$*/\n" + "context IteratorExp\n" + "def: IsTrue() : Boolean = true\n" + "inv True: IsTrue()\n" + "endpackage\n"; String pasteText = "context IterateExp\n" + "inv False: true\n"; CSResource xtextResource; Resource asResource; { // URI ecoreURI1 = getProjectFileURI("test1.ecore"); URI outputURI = getProjectFileURI("test.ocl"); xtextResource = ocl.getCSResource(outputURI, testDocument); asResource = cs2as(ocl, xtextResource, null); assertNoResourceErrors("Loading", xtextResource); assertNoValidationErrors("Loading", xtextResource); assertNoResourceErrors("Loading", asResource); assertNoValidationErrors("Loading", asResource); // @SuppressWarnings("unused") Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); } // // Change "/*$$*/" to "pasteText". // { replace(xtextResource, "/*$$*/", pasteText); assertNoResourceErrors("Pasting operation", xtextResource); assertNoValidationErrors("Pasting operation", xtextResource); assertNoResourceErrors("Pasting operation", asResource); assertNoValidationErrors("Pasting operation", asResource); // URI ecoreURI2 = getProjectFileURI("test2.ecore"); // @SuppressWarnings("unused") Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, false); } // // Change "pasteText" back to "/*$$*/". // { // replace(xtextResource, pasteText, "/*$$*/"); // assertNoResourceErrors("Unpasting operation", xtextResource); // assertNoValidationErrors("Unpasting operation", xtextResource); // assertNoResourceErrors("Unpasting operation", asResource); // assertNoValidationErrors("Unpasting operation", asResource); // URI ecoreURI3 = getProjectFileURI("test3.ecore"); // @SuppressWarnings("unused") Resource ecoreResource3 = as2ecore(ocl, asResource, ecoreURI3, true); } ocl.dispose(); } public void testEdit_Paste_OCLstdlib() throws Exception { OCL ocl = OCL.newInstance(getProjectMap()); String goodString = "coercion toUnlimitedNatural"; String badString = "coer cion toUnlimitedNatural"; // OCLDelegateDomain.initialize(null); // OCLDelegateDomain.initialize(null, OCLConstants.OCL_DELEGATE_URI); CommonOptions.DEFAULT_DELEGATION_MODE.setDefaultValue(PivotConstants.OCL_DELEGATE_URI_PIVOT); CSResource xtextResource; Resource asResource; { // URI ecoreURI1 = getProjectFileURI("test1.ecore"); // InputStream inputStream = new URIConverter.ReadableInputStream(testDocument, "UTF-8"); // URI outputURI = getProjectFileURI("test.ocl"); ProjectManager projectMap = ocl.getProjectManager(); projectMap.initializeResourceSet(ocl.getResourceSet()); @NonNull URI libURI = URI.createPlatformResourceURI("org.eclipse.ocl.pivot/model/OCL-2.5.oclstdlib", true); xtextResource = ocl.getCSResource(libURI); asResource = cs2as(ocl, xtextResource, null); assertNoResourceErrors("Loading", xtextResource); assertNoValidationErrors("Loading", xtextResource); assertNoResourceErrors("Loading", asResource); assertNoValidationErrors("Loading", asResource); // @SuppressWarnings("unused") Resource ecoreResource1 = as2ecore(ocl, asResource, ecoreURI1, true); } // // Change "coercion" to "coer cion" - a catastrophic syntax error // { replace(xtextResource, goodString, badString); assertResourceErrors("Pasting operation", xtextResource, "mismatched input 'coer' expecting '}'", "no viable alternative at 'type'"); // assertNoValidationErrors("Pasting operation", xtextResource); assertNoResourceErrors("Pasting operation", asResource); assertNoValidationErrors("Pasting operation", asResource); // URI ecoreURI2 = getProjectFileURI("test2.ecore"); // @SuppressWarnings("unused") Resource ecoreResource2 = as2ecore(ocl, asResource, ecoreURI2, false); } // // Change "coer cion" back to "coercion". // { replace(xtextResource, badString, goodString); assertNoResourceErrors("Unpasting operation", xtextResource); assertNoValidationErrors("Unpasting operation", xtextResource); assertNoResourceErrors("Unpasting operation", asResource); assertNoValidationErrors("Unpasting operation", asResource); // URI ecoreURI3 = getProjectFileURI("test3.ecore"); // @SuppressWarnings("unused") Resource ecoreResource3 = as2ecore(ocl, asResource, ecoreURI3, true); } ocl.dispose(); } }