Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend')
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/CodeGeneratorComponent.java89
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/CodeGeneratorModule.java87
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AbstractTestTemplate.xtend163
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AllPackageTestsTemplate.xtend45
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AppearanceTestTemplate.xtend35
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/CodegenContext.xtend72
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DeleteTestTemplate.xtend33
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DirectEditTestTemplate.xtend35
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DropTestTemplate.xtend55
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/Importator.xtend87
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/PapyrusDiagramCanonicalTests.xtend93
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/Queries.java83
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/SynchronizationTestTemplate.xtend72
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TemplateQueries.xtend174
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestChildLabelNodeTemplate.xtend24
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestLinkTemplate.xtend23
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestNodeTemplate.xtend40
17 files changed, 0 insertions, 1210 deletions
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/CodeGeneratorComponent.java b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/CodeGeneratorComponent.java
deleted file mode 100644
index 89e76d69513..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/CodeGeneratorComponent.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend;
-
-
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.mwe.core.WorkflowContext;
-import org.eclipse.emf.mwe.core.issues.Issues;
-import org.eclipse.emf.mwe.core.lib.WorkflowComponentWithModelSlot;
-import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;
-import org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory;
-import org.eclipse.papyrus.tests.framework.m2t.xtend.templates.CodegenContext;
-import org.eclipse.papyrus.tests.framework.m2t.xtend.templates.PapyrusDiagramCanonicalTests;
-import org.eclipse.uml2.uml.Model;
-
-import com.google.common.base.Supplier;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * The step in the test framework workflow that generates the test code from the UML-UTP test model.
- */
-public class CodeGeneratorComponent extends WorkflowComponentWithModelSlot {
-
- private String tempSrcPath = null;
- private Log log = LogFactory.getLog(getClass());
-
- private final Injector injector;
-
- @Inject
- private PapyrusDiagramCanonicalTests canonicalTests;
-
- @Inject
- private CodegenContext codegenContext;
-
- public CodeGeneratorComponent(Supplier<? extends CodeGeneratorModule> codegenModule) {
- injector = Guice.createInjector(codegenModule.get());
- injector.injectMembers(this);
- }
-
- public String getTempSrcPath() {
- return tempSrcPath;
- }
-
- public void setTempSrcPath(String tempSrcPath) {
- this.tempSrcPath = tempSrcPath;
- }
-
- @Override
- protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
- Issues issues) {
- log.info("Generating code...");
- Object modelSlotContent = ctx.get(getModelSlot());
- Model model = null;
- if (modelSlotContent instanceof Model) {
- model = (Model) modelSlotContent;
- } else if (modelSlotContent instanceof List) {
- List<?> slotContentList = (List<?>) modelSlotContent;
- model = (Model) slotContentList.get(0);
- }
- if (model == null || !(model instanceof Model)) {
- log.error("The input model for the generation was not loaded!");
- }
- EcoreUtil.resolveAll(model);
-
- codegenContext.setOutputFolderPath(tempSrcPath);
- codegenContext.setResourceLoader(ResourceLoaderFactory.createResourceLoader());
-
- canonicalTests.generate(model);
- log.info("The code was succesfully generated in " + tempSrcPath);
- }
-
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/CodeGeneratorModule.java b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/CodeGeneratorModule.java
deleted file mode 100644
index 95fba8f99fc..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/CodeGeneratorModule.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2015 Christian W. Damus 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:
- * Christian W. Damus - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.tests.framework.m2t.xtend;
-
-import com.google.inject.AbstractModule;
-
-/**
- * Guice module for the Xtend code generator.
- */
-public class CodeGeneratorModule extends AbstractModule {
-
- public CodeGeneratorModule() {
- super();
- }
-
- @Override
- protected void configure() {
- bindImportator();
- bindPapyrusDiagramCanonicalTests();
-
- bindTemplateQueries();
- bindAllPackageTestsTemplate();
- bindAppearanceTestTemplate();
- bindDeleteTestTemplate();
- bindDropTestTemplate();
- bindEditionTestTemplate();
- bindTestChildLabelNodeTestTemplate();
- bindTestLinkTemplate();
- bindTestNodeTemplate();
- }
-
- protected void bindImportator() {
- // Pass
- }
-
- private void bindTemplateQueries() {
- // Pass
- }
-
- protected void bindPapyrusDiagramCanonicalTests() {
- // Pass
- }
-
- protected void bindAllPackageTestsTemplate() {
- // Pass
- }
-
- protected void bindAppearanceTestTemplate() {
- // Pass
- }
-
- protected void bindDeleteTestTemplate() {
- // Pass
- }
-
- protected void bindDropTestTemplate() {
- // Pass
- }
-
- protected void bindEditionTestTemplate() {
- // Pass
- }
-
- protected void bindTestChildLabelNodeTestTemplate() {
- // Pass
- }
-
- protected void bindTestLinkTemplate() {
- // Pass
- }
-
- protected void bindTestNodeTemplate() {
- // Pass
- }
-
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AbstractTestTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AbstractTestTemplate.xtend
deleted file mode 100644
index 966fb4fd637..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AbstractTestTemplate.xtend
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2015 Christian W. Damus 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:
- * Christian W. Damus - Initial API and implementation
- *
- */
-
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import static extension com.google.common.base.Strings.nullToEmpty
-
-import org.eclipse.uml2.uml.Activity
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.InstanceValue
-import org.eclipse.uml2.uml.Operation
-import javax.inject.Inject
-import org.eclipse.uml2.uml.ValuePin
-import org.eclipse.uml2.uml.InstanceSpecification
-import org.eclipse.uml2.uml.ValueSpecification
-import org.eclipse.uml2.uml.OpaqueExpression
-import org.eclipse.uml2.uml.CallOperationAction
-import org.eclipse.uml2.uml.LiteralString
-
-/**
- * Common structure for all generated test classes. Provides several abstract or default-blank snippets
- * that subclasses should override to plug in specific code fragments.
- */
-abstract class AbstractTestTemplate {
- @Inject protected extension Queries
- @Inject protected extension TemplateQueries
- @Inject protected extension Importator
-
- def generate(Class clazz) '''
- «javaHeader»
- package «clazz.package.name»;
-
- «markImports»
- «clazz.elementImports.map[alias].forEach[imported(packageRootName(clazz)+'.edit.parts.'+it)]»
-
- /**
- * The Class «clazz.name».
- */
- «clazz.generatedTest»
- «clazz.runWith»
- «clazz.additionalAnnotations»
- public class «clazz.name» «clazz.extendsDeclaration» {
-
- «clazz.diagramCreationMethods»
-
- «FOR Operation testCaseOperation : clazz.testCases SEPARATOR '\n'»
- «val instanceSpec = (testCaseOperation.ownedParameters.head?.defaultValue as InstanceValue)?.instance»
- /**
- * «testCaseOperation.purpose(instanceSpec?.componentName)»
- */
- «testCaseOperation.testAnnotations»
- «testCaseOperation.exclusionAnnotation»
- public void «testCaseOperation.name»() {
- «safeTestCaseBody(testCaseOperation.methods.head as Activity, clazz)»
- }
- «ENDFOR»
-
- «clazz.getDiagramUpdaterMethod»
-
- «clazz.additionalMethods»
- }
- '''
-
- def extendsDeclaration(Class class_) '''extends «imported(class_.generals.head.qualifiedJavaName)»'''
-
- def diagramCreationMethods(Class class_) '''
- @Override
- protected «imported('org.eclipse.papyrus.commands.ICreationCommand')» getDiagramCommandCreation() {
- return new «class_.diagramCreationCommand»();
- }
-
- @Override
- protected String getProjectName() {
- return «class_.constantsInterface».PROJECT_NAME;
- }
-
- @Override
- protected String getFileName() {
- return «class_.constantsInterface».FILE_NAME;
- }
- '''
-
- def getDiagramUpdaterMethod(Class class_) '''
- @Override
- public «imported('org.eclipse.papyrus.infra.gmfdiag.common.updater.DiagramUpdater')» getDiagramUpdater() {
- return «class_.diagramUpdater».«class_.diagramUpdaterInstanceField»;
- }
- '''
-
- def additionalMethods(Class class_) ''''''
-
- def runWith(Class testContext) ''''''
-
- def generatedTest(Class testContext) '''@«imported('org.eclipse.papyrus.junit.framework.classification.GeneratedTest')»'''
-
- protected def additionalAnnotations(Class testContext) ''''''
-
- abstract def CharSequence purpose(Operation testCase, String componentName)
-
- def junitTest(Operation testCase) '''@«imported('org.junit.Test')»'''
- def generatedTest(Operation testCase) ''''''
- def testAnnotations(Operation testCase) '''
- «testCase.junitTest»
- «testCase.generatedTest»
- '''
-
- def exclusionAnnotation(Operation testCase) '''
- «val pre = testCase.exclusionPrecondition»
- «IF pre != null»
- @«pre.name.imported»("«pre.specification.stringValue»")
- «ENDIF»
- '''
-
- protected def getExclusionPrecondition(Operation testCase) {
- testCase.preconditions.findFirst[
- (name != null) && (specification instanceof LiteralString)
- ]
- }
-
- private def safeTestCaseBody(Activity method, Class class_) {
- try {
- testCaseBody(method, class_);
- } catch (Exception e) {
- imported('org.junit.Assert') + '.fail("Test case specification problem: ' + (e.message ?: e.class.simpleName) +'");'
- }
- }
-
- def testCaseBody(Activity method, Class class_) '''
- «FOR action : method.ownedNodes.filter(CallOperationAction)»
- «action.operation.name»(«FOR pin : action.arguments.filter(ValuePin) SEPARATOR ', '»«pin.toCallArgument(class_)»«ENDFOR»);
- «ENDFOR»
- '''
-
- protected def dispatch CharSequence toCallArgument(ValuePin pin, Class testContext)
- '''«pin.value.toCallArgument(testContext)»'''
-
- protected def dispatch toCallArgument(ValueSpecification value, Class testContext)
- '''«value.stringValue»'''
-
- protected def dispatch toCallArgument(LiteralString value, Class testContext)
- '''"«value.stringValue.nullToEmpty.replace('"', '\\"')»"'''
-
- protected def dispatch toCallArgument(InstanceValue value, Class testContext) {
- var node = value.instance as InstanceSpecification
- val umlElementTypes = imported(packageRootName(testContext) + '.providers.UMLElementTypes')
- '''«umlElementTypes».getElementType(«node.getStringSlotValue('editPartClassName')».VISUAL_ID)'''
- }
-
- protected def dispatch toCallArgument(OpaqueExpression value, Class testContext) {
- val index = value.languages.indexOf('Java')
- '''«value.bodies.get(index)»'''
- }
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AllPackageTestsTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AllPackageTestsTemplate.xtend
deleted file mode 100644
index 660ab79cb30..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AllPackageTestsTemplate.xtend
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import java.util.List
-import javax.inject.Inject
-
-/**
- * Code generation template for the all-tests suite of a test package. Also used for the top-level all-tests
- * suite that aggregates the suite for each package.
- */
-class AllPackageTestsTemplate {
- @Inject extension TemplateQueries
- @Inject extension Importator
-
- def generate(String className, String packageName, List<String> classes ) '''
- «javaHeader»
- package «packageName»;
-
- «markImports()»
-
- /**
- * All test in canonical package
- */
- @«imported('org.junit.runner.RunWith')»(«imported('org.eclipse.papyrus.junit.framework.classification.ClassificationSuite')».class)
- @«imported('org.junit.runners.Suite.SuiteClasses')»({
- «FOR String clazz : classes»
- «imported(clazz)».class,
- «ENDFOR»
- })
- @«imported('org.eclipse.papyrus.junit.framework.classification.GeneratedTest')»
- public class «className» {
- }
- '''
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AppearanceTestTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AppearanceTestTemplate.xtend
deleted file mode 100644
index 6d7cdf29f2c..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/AppearanceTestTemplate.xtend
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.Operation
-
-/**
- * Code generation template for the appearance tests class for an edit-part.
- */
-class AppearanceTestTemplate extends AbstractTestTemplate {
-
- override diagramCreationMethods(Class class_) '''
- @Override
- public «imported('org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart')» getContainerEditPart() {
- return getDiagramEditPart();
- }
-
- «super.diagramCreationMethods(class_)»
- '''
-
- override getDiagramUpdaterMethod(Class class_) ''''''
-
- override purpose(Operation testCase, String componentName) '''Test the appearance properties of «componentName».'''
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/CodegenContext.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/CodegenContext.xtend
deleted file mode 100644
index 348c191c451..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/CodegenContext.xtend
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2015 Christian W. Damus 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:
- * Christian W. Damus - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.xtend.lib.annotations.Accessors
-import javax.inject.Inject
-import java.io.File
-import java.io.FileWriter
-import com.google.common.io.Closeables
-import javax.inject.Singleton
-import org.eclipse.emf.mwe.core.resources.ResourceLoader
-
-/**
- * A code generation context for the Xtend templates.
- */
- @Singleton
-class CodegenContext {
- @Inject extension TemplateQueries
- @Inject extension Importator
-
- @Accessors String outputFolderPath
-
- @Accessors ResourceLoader resourceLoader
-
- def create new File(outputFolderPath) outputFolder() {
- // Pass
- }
-
- def create new File(outputFolder, package_.computePackagePath) outputFolder(org.eclipse.uml2.uml.Package package_) {
- if (!it.exists) it.mkdirs
- }
-
- def outputFile(org.eclipse.uml2.uml.Class class_) {
- class_.nearestPackage.outputFile(class_.name)
- }
-
- def create new File(package_.outputFolder, class_ + '.java') outputFile(org.eclipse.uml2.uml.Package package_, String class_) {
- // Pass
- }
-
- def createClass(org.eclipse.uml2.uml.Package package_, String className, () => CharSequence template) {
- createFile(package_.outputFile(className), template)
- }
-
- def createFile(org.eclipse.uml2.uml.Package package_, String fileName, () => CharSequence template) {
- createFile(new File(package_.outputFolder, fileName), template)
- }
-
- def createFile(org.eclipse.uml2.uml.Class class_, () => CharSequence template) {
- createFile(class_.outputFile, template)
- }
-
- def createFile(File file, () => CharSequence template) {
- val writer = new FileWriter(file)
- try {
- writer.write(managingImports(file, template).toString)
- } finally {
- Closeables.close(writer, true)
- }
- }
-} \ No newline at end of file
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DeleteTestTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DeleteTestTemplate.xtend
deleted file mode 100644
index 3b801c37abf..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DeleteTestTemplate.xtend
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.Operation
-
-/**
- * Template for the edit-part deletion tests class for an edit-part.
- */
-class DeleteTestTemplate extends AbstractTestTemplate {
-
- override diagramCreationMethods(Class class_) '''
- @Override
- public «imported('org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart')» getContainerEditPart() {
- return getDiagramEditPart();
- }
-
- «super.diagramCreationMethods(class_)»
- '''
-
- override purpose(Operation testCase, String componentName) '''Test the deletion of «componentName».'''
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DirectEditTestTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DirectEditTestTemplate.xtend
deleted file mode 100644
index 0cabc9d3d1f..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DirectEditTestTemplate.xtend
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.Operation
-
-/**
- * Template for the direct-edit tests for an edit-part.
- */
-class DirectEditTestTemplate extends AbstractTestTemplate {
-
- override diagramCreationMethods(Class class_) '''
- @Override
- public «imported('org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart')» getContainerEditPart() {
- return getDiagramEditPart();
- }
-
- «super.diagramCreationMethods(class_)»
- '''
-
- override getDiagramUpdaterMethod(Class class_) ''''''
-
- override purpose(Operation testCase, String componentName) '''Test the direct-edit of «componentName».'''
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DropTestTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DropTestTemplate.xtend
deleted file mode 100644
index ef9eea05465..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/DropTestTemplate.xtend
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.uml2.uml.Activity
-import org.eclipse.uml2.uml.CallOperationAction
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.InstanceValue
-import org.eclipse.uml2.uml.Operation
-import org.eclipse.uml2.uml.ValuePin
-
-/**
- * Template for the drag-and-drop tests class for an edit-part.
- */
-class DropTestTemplate extends AbstractTestTemplate {
-
- override diagramCreationMethods(Class class_) '''
- @Override
- public «imported('org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart')» getContainerEditPart() {
- return getDiagramEditPart();
- }
-
- «super.diagramCreationMethods(class_)»
- '''
-
- override getDiagramUpdaterMethod(Class class_) ''''''
-
- override purpose(Operation testCase, String componentName) '''Test to drop «componentName».'''
-
- override testCaseBody(Activity method, Class class_) '''
- «FOR action : method.ownedNodes.filter(CallOperationAction)»
- «val pin = action.arguments.head as ValuePin»
- «val node = (pin.value as InstanceValue).instance»
- «action.operation.name»(«pin.toCallArgument(class_)», «node.umlPackageElementType», true);
- «ENDFOR»
- '''
-
- override additionalMethods(Class class_) '''
- @Override
- protected «imported('org.eclipse.gmf.runtime.notation.View')» getRootView() {
- return («imported('org.eclipse.gmf.runtime.notation.View')»)getContainerEditPart().getModel();
- }
- '''
-
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/Importator.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/Importator.xtend
deleted file mode 100644
index bb720f81ee2..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/Importator.xtend
+++ /dev/null
@@ -1,87 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2015 Christian W. Damus 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:
- * Christian W. Damus - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import java.util.Map
-import com.google.common.collect.Maps
-import com.google.common.base.Joiner
-import com.google.common.collect.Iterables
-import com.google.common.collect.Ordering
-import javax.inject.Singleton
-import java.io.File
-
-/**
- * Extensions for managing imports in generated Java files.
- */
- @Singleton
-class Importator {
- Map<File, Map<String, String>> importsByFile = Maps.newHashMap
- ThreadLocal<File> tlFile = new ThreadLocal;
-
- def reset() {
- imports.clear
- }
-
- def CharSequence managingImports(File file, () => CharSequence template) {
- var CharSequence result = null
-
- tlFile.set(file)
- try {
- result = importify(template.apply)
- } finally {
- tlFile.remove
- importsByFile.remove(file)
- }
-
- result
- }
-
- private def file() {
- tlFile.get
- }
-
- def imports() {
- if (importsByFile.containsKey(file))
- importsByFile.get(file)
- else
- Maps.newHashMap => [
- importsByFile.put(file, it)
- ]
- }
-
- def String imported(String qualifiedClassName) {
- val simpleName = qualifiedClassName.substring(qualifiedClassName.lastIndexOf('.') + 1)
- val existing = imports.get(simpleName)
-
- if ((simpleName == qualifiedClassName) || ((existing != null) && (existing != qualifiedClassName))) {
- // Cannot import the same name again
- qualifiedClassName
- } else {
- imports.put(simpleName, qualifiedClassName)
- simpleName
- }
- }
-
- def String markImports() {
- "$$$imports$$$"
- }
-
- private def CharSequence importify(CharSequence text) {
- val importsText = Joiner.on(System.getProperty("line.separator")).join(
- Iterables.transform(Ordering.natural.sortedCopy(imports.values), [f|'import ' + f + ';'])
- )
-
- text.toString.replaceFirst("\\$\\$\\$imports\\$\\$\\$", importsText)
- }
-} \ No newline at end of file
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/PapyrusDiagramCanonicalTests.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/PapyrusDiagramCanonicalTests.xtend
deleted file mode 100644
index e62293e97c7..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/PapyrusDiagramCanonicalTests.xtend
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import java.util.ArrayList
-import java.util.List
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.Model
-import org.eclipse.uml2.uml.Package
-import javax.inject.Inject
-
-/**
- * The main entry-point rule for the model-to-text transformation that generates the test code
- * from a UML-UTP model describing the diagram test cases.
- */
-class PapyrusDiagramCanonicalTests {
- @Inject extension TemplateQueries
- @Inject extension CodegenContext
-
- @Inject AllPackageTestsTemplate allPackageTests
- @Inject AppearanceTestTemplate appearanceTests
- @Inject DirectEditTestTemplate directEditTests
- @Inject DeleteTestTemplate deleteTests
- @Inject DropTestTemplate dropTests
- @Inject TestChildLabelNodeTemplate childLabelNodeTests
- @Inject TestLinkTemplate linkTests
- @Inject TestNodeTemplate nodeTests
- @Inject SynchronizationTestTemplate synchronizationTests
-
- def generate(Model model) {
- var List<String> suiteClasses = new ArrayList<String>
- for (Package subpackage : model.ownedElements.filter(Package)){
- val allTestClasses = subpackage.allOwnedElements.filter(Class)
- .filter[getAppliedStereotype("utp::TestContext") != null]
- .filter[!ownedAttributes.empty]
- .filter[hasTestCases]
-
- if (!allTestClasses.empty) {
- for (Class clazz : allTestClasses) {
-
- // Invoke the proper template for the class
- val superClass = clazz.generals.head as Class
-
- createFile(clazz) [
- switch superClass.name {
- case "AbstractCreateNodeFromPaletteTest": nodeTests.generate(clazz)
- case "AbstractCreateLinkFromPaletteTest": linkTests.generate(clazz)
- case "AbstractCreateChildLabelNodeFromPaletteTest": childLabelNodeTests.generate(clazz)
- case "AbstractCreateLinkOwnedBySourceFromPaletteTest": linkTests.generate(clazz)
- case "AbstractAppearanceNodeTest": appearanceTests.generate(clazz)
- case "AbstractDropNodeTest": dropTests.generate(clazz)
- case "AbstractDeleteNodeTest": deleteTests.generate(clazz)
- case "AbstractEditableNodeTest": directEditTests.generate(clazz)
- case "AbstractSynchronizationTest",
- case "AbstractCSSSynchronizationTest" : synchronizationTests.generate(clazz)
- default: throw new RuntimeException("Type of test not recognized: " + superClass.name)
- }
- ]
- }
- var className = generatePackageTestSuiteClass(subpackage, allTestClasses)
- suiteClasses.add(className);
- }
- }
- generateAllTestSuiteClass(model, suiteClasses)
- }
-
- def generateAllTestSuiteClass(Package model, List<String> testSuiteNames) {
- val className = "AllGenTests"
- createClass(model, className) [
- allPackageTests.generate(className, model.name, testSuiteNames);
- ]
- }
-
- def generatePackageTestSuiteClass(Package package_, Iterable<Class> allTestClasses) {
- val packageName = package_.name
- val className = "All" + packageName.substring(packageName.lastIndexOf('.') + 1).toFirstUpper + "Tests"
- createClass(package_, className) [
- allPackageTests.generate(className, packageName, allTestClasses.toList.map[name]);
- ]
-
- packageName + '.' + className
- }
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/Queries.java b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/Queries.java
deleted file mode 100644
index 3c0769c130d..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/Queries.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.uml2.uml.InstanceSpecification;
-import org.eclipse.uml2.uml.InstanceValue;
-import org.eclipse.uml2.uml.LiteralString;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Slot;
-import org.eclipse.uml2.uml.StructuralFeature;
-import org.eclipse.uml2.uml.ValueSpecification;
-
-/**
- * Helper query operations for introspection of the UML-UTP model describing diagram test cases,
- * for use in the Xtend transformation pipeline.
- */
-public class Queries {
-
- public InstanceSpecification getDefaultValueInstanceSpecification(org.eclipse.uml2.uml.Class clazz, String propertyName) {
- EList<Property> attributes = clazz.getAttributes();
- for (Property attribute : attributes) {
- if (attribute.getName().equalsIgnoreCase(propertyName)) {
- return ((InstanceValue) attribute.getDefaultValue()).getInstance();
- }
- }
- throw new RuntimeException("Attribute '" + propertyName + "' not found in class " + clazz.getName());
- }
-
- public String getStringSlotValue(InstanceSpecification instanceSpecification, String slotName) {
- if (instanceSpecification == null)
- throw new RuntimeException("instance argument is null!");
- EList<Slot> slots = instanceSpecification.getSlots();
- for (Slot slot : slots) {
- StructuralFeature definingFeature = slot.getDefiningFeature();
- String name = definingFeature.getName();
- if (name.equalsIgnoreCase(slotName)) {
- EList<ValueSpecification> values = slot.getValues();
- ValueSpecification value = values.get(0);
- return ((LiteralString) value).getValue();
- }
- }
- throw new RuntimeException("Slot _" + slotName + "_ not found in instance " + instanceSpecification);
- }
-
- public InstanceSpecification getInstanceSlotValue(InstanceSpecification instance, String slotName) {
- if (instance == null)
- throw new RuntimeException("instance argument is null!");
- if (instance.eIsProxy()) {
- EcoreUtil.resolve(instance, instance.eResource());
- }
- EList<Slot> slots = instance.getSlots();
- for (Slot slot : slots) {
- if (slot.getDefiningFeature().getName().equalsIgnoreCase(slotName)) {
- if (slot.getValues().isEmpty()) {
- throw new RuntimeException(slotName + " in " + instance + " has no values");
- }
- ValueSpecification value = slot.getValues().get(0);
- InstanceSpecification instanceSpec = ((InstanceValue) value).getInstance();
- if (instanceSpec.eIsProxy()) {
- EcoreUtil.resolve(instanceSpec, instance.eResource());
- }
- return instanceSpec;
- }
- }
- throw new RuntimeException("Slot _" + slotName + "_ not found in instance " + instance);
- }
-
- public String getSlotValueDefaultInstanceSpecification(org.eclipse.uml2.uml.Class clazz, String propertyName, String slotName) {
- return getStringSlotValue(getDefaultValueInstanceSpecification(clazz, propertyName), slotName);
- }
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/SynchronizationTestTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/SynchronizationTestTemplate.xtend
deleted file mode 100644
index 40173bac565..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/SynchronizationTestTemplate.xtend
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2015 Christian W. Damus 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:
- * Christian W. Damus - Initial API and implementation
- *
- */
-
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import javax.inject.Inject
-import org.eclipse.uml2.uml.Activity
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.InstanceValue
-import org.eclipse.uml2.uml.InvocationAction
-import org.eclipse.uml2.uml.ValuePin
-import org.eclipse.uml2.uml.InputPin
-import org.eclipse.uml2.uml.Operation
-
-/**
- * Common structure of the model-view synchronization tests for an edit-part. Provides several
- * abstract or default-blank snippets that subclasses should override to plug in specific code fragments.
- */
-class SynchronizationTestTemplate extends AbstractTestTemplate {
- @Inject protected extension TemplateQueries
- @Inject protected extension Importator
-
- protected def syncTestKind(Class testContext) {
- testContext.getOwnedAttribute('syncTestKind', null)?.defaultValue?.stringValue
- }
-
- override additionalAnnotations(Class testContext) {
- val org.eclipse.uml2.uml.Property css = testContext.getAttribute('css', null);
- if (css != null) {
- '''@«'org.eclipse.papyrus.uml.diagram.tests.synchronization.AbstractCSSSynchronizationTest.CSS'.imported»("«css.defaultValue.stringValue»")'''
- } else {
- super.additionalAnnotations(testContext)
- }
- }
-
- override purpose(Operation testCase, String componentName) {
- switch (testCase.class_.syncTestKind) {
- case 'labelnode' : '''Test to synchronize child label node «componentName».'''
- case 'childnode' : '''Test to synchronize child node «componentName».'''
- case 'link' : '''Test to synchronize link «componentName».'''
- default: '''Test to synchronize node «componentName».'''
- }
- }
-
- override getDiagramUpdaterMethod(Class class_) ''''''
-
- protected def instanceValue(Activity method, String pinName) {
- (method.ownedNodes.head as InvocationAction).instanceValue(pinName)
- }
-
- protected def instanceValue(InvocationAction action, String pinName) {
- action.arguments.findFirst[name == pinName].instanceValue
- }
-
- protected def instanceValue(InputPin pin) {
- ((pin as ValuePin).value as InstanceValue).instance
- }
-
- protected def umlElementTypes(Class class_) {
- (class_.packageRootName + '.providers.UMLElementTypes').imported
- }
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TemplateQueries.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TemplateQueries.xtend
deleted file mode 100644
index a795d285eb8..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TemplateQueries.xtend
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.InstanceSpecification
-import org.eclipse.uml2.uml.Package
-import org.eclipse.uml2.uml.Property
-import javax.inject.Singleton
-import javax.inject.Inject
-import org.eclipse.uml2.uml.Expression
-import java.util.Calendar
-import org.eclipse.uml2.uml.NamedElement
-import com.google.common.io.Resources
-import com.google.common.base.Charsets
-import org.eclipse.papyrus.tests.framework.xtend.annotations.Cached
-
-/**
- * Helper query operations and template snippets for the model-to-text transformations
- * that generate test class code from the UML-UTP model describing a diagram's test cases.
- */
-@Singleton
-class TemplateQueries {
- @Inject extension CodegenContext
- @Inject extension Importator
- @Inject extension Queries
-
- def javaHeader() '''
- /*****************************************************************************
- * Copyright (c) «thisYear» CEA LIST 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
- *
- * This file has been generated automatically in the Papyrus Test Framework.
- *
- *****************************************************************************/
- '''
-
- private def create Calendar.instance.get(Calendar.YEAR) thisYear() {
- // Pass
- }
-
- def getQualifiedJavaName(NamedElement element) {
- element.qualifiedName.replace('::', '.')
- }
-
- def getTestCases(Class class_) {
- class_.ownedOperations.filter[getAppliedStereotype("utp::TestCase") != null]
- }
-
- def hasTestCases(Class class_) {
- !class_.testCases.nullOrEmpty
- }
-
- def umlPackageElementType(InstanceSpecification node) {
- var componentName = getComponentName(node) as String
- if (componentName == 'Class') componentName = componentName + '_'
-
- '''«imported('org.eclipse.uml2.uml.UMLPackage')».eINSTANCE.get«componentName»()'''
- }
-
- def getComponentName(InstanceSpecification node) {
- node.getInstanceSlotValue('modelFacet').getStringSlotValue('metaClass')
- }
-
- def getDiagramName(Class clazz) {
- clazz.getDefaultValueInstanceSpecification('generator').getStringSlotValue('modelID').replace('PapyrusUML', '')
- }
-
- private def getDiagramCreationCommandName(Class clazz) {
- clazz.getAttribute('diagramCreationCommand', null)?.defaultStringValue
- }
-
- def diagramCreationCommand(Class class_) {
- resolveImportedClassName(packageRootName(class_), class_.diagramCreationCommandName, #['custom', ''])
- }
-
- def packageRootName(Class clazz) {
- clazz.getDefaultValueInstanceSpecification('generator').getStringSlotValue('packageNamePrefix')
- }
-
- def computePackagePath(Package model) {
- model.name.replace(".", System.getProperty("file.separator")) +
- //System.getProperty("file.separator") + "canonical" +
- System.getProperty("file.separator")
- }
-
- private def constantsInterfaceName(Class class_) {
- class_.getAttribute('testConstantsInterface', null)?.defaultStringValue
- }
-
- def constantsInterface(Class class_) {
- resolveImportedClassName(class_.packageRootName, class_.constantsInterfaceName, #['test', 'tests'])
- }
-
- private def diagramUpdaterName(Class class_) {
- class_.getAttribute('diagramUpdater', null)?.defaultStringValue
- }
-
- def defaultStringValue(Property property) {
- val value = property.defaultValue
-
- switch (value) {
- case null: ''
- Expression: value.symbol // XXX Why do we use an expression symbol to store the updater name?
- default: value.stringValue
- }
- }
-
- def diagramUpdater(Class class_) {
- class_.resolveDiagramUpdater.imported
- }
-
- private def resolveDiagramUpdater(Class class_) {
- resolveClassName(class_.packageRootName, class_.diagramUpdaterName,
- #['custom.edit.part', 'custom.edit.parts', 'custom.part', 'edit.part', 'edit.parts', 'part']
- )
- }
-
- @Cached
- def diagramUpdaterInstanceField(Class class_) {
- val resourceName = class_.resolveDiagramUpdater.replace('.', '/') + '.class'
- val resourceURL = resourceLoader.getResource(resourceName)
- if (resourceURL == null) {
- 'INSTANCE'
- } else {
- // Quick hack to look for legacy field name
- try {
- val contents = Resources.toString(resourceURL, Charsets.UTF_8)
- if (contents.contains('TYPED_INSTANCE')) 'TYPED_INSTANCE' else 'INSTANCE'
- } catch (Exception e) {
- 'INSTANCE'
- }
- }
- }
-
- def String resolveImportedClassName(String rootPackage, String name, Iterable<String> searchPath) {
- rootPackage.resolveClassName(name, searchPath).imported
- }
-
- @Cached
- def String resolveClassName(String rootPackage, String name, Iterable<String> searchPath) {
- val search = searchPath.map [
- val prefix = if (it.startsWith(rootPackage+'.')) it else rootPackage + '.' + it
-
- // Account for a '' search path, which results in the prefix ending with a '.'
- if (prefix.endsWith('.')) prefix + name else prefix + '.' + name
- ]
-
- val result = search.findFirst [
- try {
- // The diagram plug-in is on our classpath, so look for the class
- resourceLoader.getResource(it.replace('.', '/') + '.class') != null
- } catch (Exception e) {
- false
- }
- ]
-
- result ?: search.last
- }
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestChildLabelNodeTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestChildLabelNodeTemplate.xtend
deleted file mode 100644
index 6ef2c91ff1e..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestChildLabelNodeTemplate.xtend
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.uml2.uml.Operation
-
-/**
- * Template for the tests class for creation of label-node edit parts.
- */
-class TestChildLabelNodeTemplate extends AbstractTestTemplate {
-
- override purpose(Operation testCase, String componentName) '''Test to create child label nodes.'''
-
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestLinkTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestLinkTemplate.xtend
deleted file mode 100644
index 92bef38f3c3..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestLinkTemplate.xtend
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.uml2.uml.Operation
-
-/**
- * Template for the tests class for creation of link edit-parts.
- */
-class TestLinkTemplate extends AbstractTestTemplate {
-
- override purpose(Operation testCase, String componentName) '''Test to create link «componentName».'''
-}
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestNodeTemplate.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestNodeTemplate.xtend
deleted file mode 100644
index 2ddb6c0c45b..00000000000
--- a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/m2t/xtend/templates/TestNodeTemplate.xtend
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 464647
- *
- ******************************************************************************/
-package org.eclipse.papyrus.tests.framework.m2t.xtend.templates
-
-import org.eclipse.uml2.uml.Activity
-import org.eclipse.uml2.uml.CallOperationAction
-import org.eclipse.uml2.uml.Class
-import org.eclipse.uml2.uml.Operation
-import org.eclipse.uml2.uml.ValuePin
-
-/**
- * Template for the test class for creation of a top-node edit-part.
- */
-class TestNodeTemplate extends AbstractTestTemplate {
-
- override purpose(Operation testCase, String componentName) '''Test to create node «componentName».'''
-
- override testCaseBody(Activity method, Class class_) '''
- «FOR action : method.ownedNodes.filter(CallOperationAction)»
- testCreateNodeFromPalette(«FOR pin : action.arguments.filter(ValuePin) SEPARATOR ', '»«pin.toCallArgument(class_)»«ENDFOR»);
- «ENDFOR»
- '''
-
- override additionalMethods(Class class_) '''«IF (class_.getAttribute('containerEditPart', null) != null)»
- @Override
- protected «imported('org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest')» createViewRequestShapeContainer() {
- return «imported('org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory')».getCreateShapeRequest(«imported(class_.packageRootName + '.providers.UMLElementTypes')».getElementType(«class_.getDefaultValueInstanceSpecification('containerEditPart').getStringSlotValue('editPartClassName')».VISUAL_ID), getDiagramEditPart().getDiagramPreferencesHint());
- }
- «ENDIF»'''
-}

Back to the top