blob: ede9d36d5ffcc9862bf0e8de217041c5dd99d7f6 [file] [log] [blame]
[comment]
Copyright 2010 Obeo
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 1.0
Any license can be applied to the files generated with this template.
author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
[/comment]
[module SwitchTest('http://www.eclipse.org/emf/2002/GenModel', 'http://www.eclipse.org/emf/2002/Ecore')/]
[import Common/]
[template public switchTest(pack : GenPackage)]
[file ('src-gen/'.concat(pack.testPackage().substituteAll('.', '/').concat('/unit/')).concat(pack.prefix.toUpperFirst()).concat('SwitchTest.java'), false)]
package [pack.testPackage().concat('.unit')/];
import junit.framework.TestCase;
import [pack.modelPackage()/].[pack.modelFactoryClassName()/];
import [pack.modelPackage()/].util.[pack.modelSwitchClassName()/];
[for (eClass : EClass | pack.genClasses.ecoreClass->select(not abstract))]
import [pack.modelPackage()/].[eClass.name/];
[/for]
/*
* TODO This is but a skeleton for the tests of [pack.modelSwitchClassName()/].
* Set as "generated NOT" and override each test if you overrode the default generated
* behavior.
*/
/**
* Tests the behavior of the {@link [pack.modelSwitchClassName()/] generated switch} for package [pack.ecorePackage.name/].
*
* @generated
*/
@SuppressWarnings("nls")
public class [pack.modelSwitchClassName()/]Test extends TestCase {
[for (eClass : EClass | pack.genClasses.ecoreClass) separator('\n') ? (not interface)]
/**
* Ensures that the generated switch knows {@link [eClass.name/]}.
*
* @generated
*/
public void testCase[eClass.name.toUpperFirst()/]() {
[pack.modelSwitchClassName()/]<?> [pack.ecorePackage.name.toLowerFirst()/]switch = new [pack.modelSwitchClassName()/]<Object>();
assertNull([pack.ecorePackage.name.toLowerFirst()/]switch.case[eClass.name.toUpperFirst()/]([instanceCreator(pack, eClass)/]));
assertNull([pack.ecorePackage.name.toLowerFirst()/]switch.doSwitch([instanceCreator(pack, eClass)/]));
}
[/for]
}
[/file]
[/template]
[query private instanceCreator(pack : GenPackage, eClass : EClass) : String = if not eClass.abstract then pack.modelFactoryClassName().concat('.eINSTANCE.create').concat(eClass.name.toUpperFirst()).concat('()') else if not eClass.interface then 'new '.concat(eClass.qualifiedGeneratedImplementation()).concat('(){}') else '' endif endif/]