Author: fdesbois Date: 2009-05-04 12:58:51 +0000 (Mon, 04 May 2009) New Revision: 493 Added: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelEnumeration.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelEnumerationImpl.java eugene/trunk/src/test/resources/xmi/1.2/enumeration.xmi Modified: eugene/trunk/pom.xml eugene/trunk/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModel.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/DigesterObjectModelRuleSet.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelDependencyImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java eugene/trunk/src/main/xsl/xmi1.2ToObjectModel.xsl eugene/trunk/src/main/xsl/xmi2.1ToObjectModel.xsl eugene/trunk/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI12ToObjectModelTest.java Log: Ajout gestion des enumerations dans ObjectModel Modified: eugene/trunk/pom.xml =================================================================== --- eugene/trunk/pom.xml 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/pom.xml 2009-05-04 12:58:51 UTC (rev 493) @@ -156,6 +156,7 @@ </configuration> <executions> <execution> + <phase>package</phase> <goals> <goal>single</goal> </goals> Modified: eugene/trunk/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java 2009-05-04 12:58:51 UTC (rev 493) @@ -23,6 +23,7 @@ import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; +import java.util.Collection; import java.util.Enumeration; import java.util.List; import java.util.regex.Matcher; @@ -45,6 +46,7 @@ import org.codelutin.util.FileUtil; import org.codelutin.util.RecursiveProperties; import org.codelutin.util.StringUtil; +import org.nuiton.eugene.models.object.ObjectModelEnumeration; import org.xml.sax.SAXException; /** @@ -279,10 +281,12 @@ * Par defaut la methode appelle la methode * {@link #generateFromModel(Writer, ObjectModel)} puis boucle sur chaque * class en appelant la m?thode - * {@link #generateFromClass(Writer, ObjectModelClass)} et enfin sur chaque + * {@link #generateFromClass(Writer, ObjectModelClass)} puis boucle sur chaque * interface en appelant a méthode - * {@link #generateFromInterface(Writer, ObjectModelInterface)} Le nom de - * fichier est récupérer pour chacun d'eux en appelant la méthode + * {@link #generateFromInterface(Writer, ObjectModelInterface)} et enfin sur chaque + * énumération en appelant la méthode + * {@link #generateFromEnumeration(Writer, ObjectModelEnumeration)} + * Le nom de fichier est récupérer pour chacun d'eux en appelant la méthode * getFilenameFor.... La methode generateFrom... n'utilise pas le Writer * alors le fichier n'est pas généré, si on l'utilise m?me pour ne rien * écrire alors le fichier sera généré. @@ -408,9 +412,89 @@ eee); } } + + // generateFromEnumeration + generateFromElements(model.getEnumerations(), destDir); } /** + * Parcours une collection d'éléments pour la génération suivant un type d'éléments. + * Types possibles : ObjectModelClassifier, ObjectModelClass, ObjectModelInterface et + * ObjectModelEnumeration. + * Deux méthodes dépendent du type et peuvent être surchargées : + * getFilenameForXXX et generateFromXXX (XXX étant un type prédéfini pour une méthode existante). + * @param elements Collection d'éléments d'un des types ci-dessus + * @param destDir dossier de destination pour le fichier généré + */ + private void generateFromElements(Collection elements, File destDir) { + for (Object element : elements) { + + String filename = ""; + // Filename depends on type of element (Classifier, Class, Interface or Enumeration) + if (element instanceof ObjectModelClassifier) { + filename = getFilenameForClassifier((ObjectModelClassifier)element); + } else if (element instanceof ObjectModelClass) { + filename = getFilenameForClass((ObjectModelClass)element); + } else if (element instanceof ObjectModelInterface) { + filename = getFilenameForInterface((ObjectModelInterface)element); + } else if (element instanceof ObjectModelEnumeration) { + filename = getFilenameForEnumeration((ObjectModelEnumeration)element); + } + + generateFromElement(element, destDir, filename); + } + } + + /** + * Génération pour un élément du modèle (ou le modèle lui-même). + * Types possibles : ObjectModel, ObjectModelClassifier, ObjectModelClass, + * ObjectModelInterface et ObjectModelEnumeration. + * La méthode generateFromXXX dépend du type d'élément et peut être surchargée. + * @param element element à généré + * @param destDir dossier de destination + * @param filename nom du fichier de sortie + */ + private void generateFromElement(Object element, File destDir, String filename) { + + File outputFile = getDestinationFile(destDir, filename); + if (!getOverwrite() && isNewerThanSource(outputFile)) { + if (log.isDebugEnabled()) { + log.debug("file " + outputFile + " is up-to-date"); + } + } else { + if (!outputFile.exists() && log.isDebugEnabled()) { + log.debug("not up-to-date " + outputFile.lastModified() + + " <" + outputFile + ">"); + } + try { + StringWriter out = new StringWriter(); + MonitorWriter monitorOut = new MonitorWriter(out); + + // Specific generation depends on element type + if (element instanceof ObjectModel) { + generateFromModel(monitorOut,(ObjectModel)element); + } else if (element instanceof ObjectModelClassifier) { + generateFromClassifier(monitorOut, (ObjectModelClassifier)element); + } else if (element instanceof ObjectModelClass) { + generateFromClass(monitorOut, (ObjectModelClass)element); + } else if (element instanceof ObjectModelInterface) { + generateFromInterface(monitorOut, (ObjectModelInterface)element); + } else if (element instanceof ObjectModelEnumeration) { + generateFromEnumeration(monitorOut, (ObjectModelEnumeration)element); + } + + write(outputFile, monitorOut); + } catch (Exception eee) { + log.warn("Erreur lors de la génération du fichier " + + outputFile); + throw new RuntimeException( + "Erreur lors de la génération du fichier " + + outputFile, eee); + } + } + } + + /** * Par defaut cette methode retourne le getName du model. Si l'on souhaite * utiliser la methode generateFromModel il vaut mieux surcharger cette * m?thode @@ -451,6 +535,10 @@ return clazz.getQualifiedName().replace('.', File.separatorChar); } + private String getFilenameForEnumeration(ObjectModelEnumeration enumeration) { + return enumeration.getQualifiedName().replace('.', File.separatorChar); + } + public void generateFromModel(Writer output, ObjectModel model) throws IOException { } @@ -466,4 +554,9 @@ public void generateFromClassifier(Writer output, ObjectModelClassifier clazz) throws IOException { } + + public void generateFromEnumeration(Writer output, + ObjectModelEnumeration enumeration) throws IOException { + } + } Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModel.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModel.java 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModel.java 2009-05-04 12:58:51 UTC (rev 493) @@ -71,6 +71,7 @@ */ public ObjectModelClass getClass(String qualifiedClassName); + /** * Indicates whether the model contains the class associated to the given className * @param qualifiedClassName - the qualified name of the class to retrieve. @@ -96,7 +97,23 @@ public ObjectModelInterface getInterface( String qualifiedInterfaceName); + /** + * Returns all enumerations defined in this model. + * @see ObjectModelEnumeration + * + * @return a Collection containing all ObjectModelEnumeration for this model. + */ + public Collection<ObjectModelEnumeration> getEnumerations(); + + /** + * Return the enumeration corresponding to the given qualified name + * @param qualifiedEnumerationName + * @return the ObjectModelEnumeration of the found enumeration or null if the model contains no enumeration for this qualified name. + */ + public ObjectModelEnumeration getEnumeration(String qualifiedEnumerationName); + + /** * Returns all comments not lied to a particular model element * * @return a List containing all comments for this model as Strings. Added: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelEnumeration.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelEnumeration.java (rev 0) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelEnumeration.java 2009-05-04 12:58:51 UTC (rev 493) @@ -0,0 +1,61 @@ +/* *##% Eugene + * Copyright (C) 2004 - 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ + +package org.nuiton.eugene.models.object; + +import java.util.Collection; + +/** + * ObjectModelEnumeration. + * + * @author Florian Desbois <fdesbois@codelutin.com> + * Copyright Code Lutin + * @version $Revision: 483 $ + * + */ +public interface ObjectModelEnumeration extends ObjectModelElement { + + /** + * Returns the package name of this enumeration. + * + * @return the package name of this enumeration. + */ + public String getPackageName(); + + /** + * Returns the qualified name of this enumeration. + * Class qualified name is composed of the package name and the enumeration name. + * + * @return the qualified name of this enumeration. + */ + public String getQualifiedName(); + + /** + * Returns literals of this enumeration. + * + * @return a Collection of String + */ + public Collection<String> getLiterals(); + + /** + * Returns all operations defined on this en enumeration. + * @see ObjectModelOperation + * + * @return a Collection containing all ObjectModelOperation for this enumeration. + */ + public Collection<ObjectModelOperation> getOperations(); +} Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/DigesterObjectModelRuleSet.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/DigesterObjectModelRuleSet.java 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/DigesterObjectModelRuleSet.java 2009-05-04 12:58:51 UTC (rev 493) @@ -78,6 +78,16 @@ d.addSetProperties("objectModel/interface"); d.addSetNext("objectModel/interface", "addInterface"); + d.addObjectCreate("objectModel/enumeration", + ObjectModelEnumerationImpl.class); + d.addSetProperties("objectModel/enumeration"); + d.addSetNext("objectModel/enumeration", "addEnumeration"); + + d.addObjectCreate("objectModel/enumeration/literal", + ObjectModelImplRef.class); + d.addSetProperties("objectModel/enumeration/literal"); + d.addSetNext("objectModel/enumeration/literal", "addLiteral"); + d.addObjectCreate("objectModel/associationClass", ObjectModelAssociationClassImpl.class); d.addSetProperties("objectModel/associationClass"); Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelDependencyImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelDependencyImpl.java 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelDependencyImpl.java 2009-05-04 12:58:51 UTC (rev 493) @@ -21,9 +21,7 @@ import org.nuiton.eugene.models.object.ObjectModelDependency; /** - * Abstraction for the root node of object model trees. - * This an entry point for browsing a model tree. This object offers - * as well several facilities for a direct access to some of the object model elements. + * ObjectModelDependencyImpl. * * Created: april 23th 2009 * Added: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelEnumerationImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelEnumerationImpl.java (rev 0) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelEnumerationImpl.java 2009-05-04 12:58:51 UTC (rev 493) @@ -0,0 +1,102 @@ +/* *##% Eugene + * Copyright (C) 2004 - 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ + +package org.nuiton.eugene.models.object.xml; + +import java.util.ArrayList; +import java.util.Collection; +import org.nuiton.eugene.models.object.ObjectModelEnumeration; +import org.nuiton.eugene.models.object.ObjectModelOperation; + +/** + * ObjectModelEnumerationImpl. + * + * Created: may 4th 2009 + * + * @author Florian Desbois <desbois@codelutin.com> + * Copyright Code Lutin + * @version $Revision: 478 $ + * + */ +public class ObjectModelEnumerationImpl extends ObjectModelElementImpl + implements ObjectModelEnumeration { + + /** + * Collection of references corresponding to literal values + */ + private Collection<ObjectModelImplRef> literalRefs = new ArrayList<ObjectModelImplRef>(); + + /** + * Collection of operations objectModel + */ + private Collection<ObjectModelOperation> operations = new ArrayList<ObjectModelOperation>(); + + /** + * Package name from objectModel file, loaded with Digester + */ + private String packageName; + + public void setPackage(String packageName) { + this.packageName = packageName; + } + + public String getPackage() { + return this.packageName; + } + /** + * Add a literal to the ObjectModelEnumeration from Digester + * @param ref corresponding to a Literal value + */ + public void addLiteral(ObjectModelImplRef ref) { + literalRefs.add(ref); + } + + /** + * Add an operation to the ObjectModelEnumeration from Digester + * @param operation + */ + public void addOperation(ObjectModelOperationImpl operation) { + operation.postInit(); + operation.setDeclaringElement(this); + operations.add(operation); + } + + @Override + public String getPackageName() { + return this.packageName; + } + + @Override + public String getQualifiedName() { + return this.packageName+"."+this.getName(); + } + + @Override + public Collection<String> getLiterals() { + Collection<String> results = new ArrayList<String>(); + for (ObjectModelImplRef ref : literalRefs) { + results.add(ref.getName()); + } + return results; + } + + @Override + public Collection<ObjectModelOperation> getOperations() { + return operations; + } + +} Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java 2009-05-04 12:58:51 UTC (rev 493) @@ -24,10 +24,13 @@ import java.util.List; import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.nuiton.eugene.models.object.ObjectModel; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; import org.nuiton.eugene.models.object.ObjectModelClassifier; +import org.nuiton.eugene.models.object.ObjectModelEnumeration; import org.nuiton.eugene.models.object.ObjectModelInterface; /** @@ -52,9 +55,12 @@ protected Map<String, ObjectModelClass> classes = new HashMap<String, ObjectModelClass>(); protected Map<String, ObjectModelInterface> interfaces = new HashMap<String, ObjectModelInterface>(); protected Map<String, ObjectModelClassifier> classifiers = new HashMap<String, ObjectModelClassifier>(); + protected Map<String, ObjectModelEnumeration> enumerations = new HashMap<String, ObjectModelEnumeration>(); protected List<String> comments = new ArrayList<String>(); private Map<String, String> tagValues = new HashMap<String, String>(); + private static Log log = LogFactory.getLog(ObjectModelImpl.class); + public void setName(String name) { this.name = name; } @@ -185,11 +191,9 @@ if (qualifiedClassName == null) { return null; } - if (!hasClass(qualifiedClassName)) { - System.out.println("WARNING : Class " + qualifiedClassName - + " not found in model"); - System.out - .println("You may forgot to declare for good an external class ?"); + if (!hasClass(qualifiedClassName) && log.isWarnEnabled()) { + log.warn("Class " + qualifiedClassName + " not found in model"); + log.warn("You may forgot to declare for good an external class ?"); } return (ObjectModelClass) classes.get(qualifiedClassName); } @@ -246,9 +250,8 @@ public ObjectModelInterface getInterface(String qualifiedInterfaceName) { ObjectModelInterface result = null; result = (ObjectModelInterface) interfaces.get(qualifiedInterfaceName); - if (result == null) { - System.out.println("WARNING : Class " + qualifiedInterfaceName - + " not found in model"); + if (result == null && log.isWarnEnabled()) { + log.warn("Interface " + qualifiedInterfaceName + " not found in model"); } return result; } @@ -264,6 +267,26 @@ return interfaces.values(); } + public void addEnumeration(ObjectModelEnumerationImpl enumeration) { + enumeration.postInit(); + enumeration.setObjectModelImpl(this); + enumerations.put(enumeration.getName(), enumeration); + } + + @Override + public Collection<ObjectModelEnumeration> getEnumerations() { + return enumerations.values(); + } + + @Override + public ObjectModelEnumeration getEnumeration(String qualifiedEnumerationName) { + ObjectModelEnumeration result = enumerations.get(qualifiedEnumerationName); + if (result == null && log.isWarnEnabled()) { + log.warn("Enumeration " + qualifiedEnumerationName + " not found in model"); + } + return result; + } + /** * Returns all comments not lied to a particular model element * Modified: eugene/trunk/src/main/xsl/xmi1.2ToObjectModel.xsl =================================================================== --- eugene/trunk/src/main/xsl/xmi1.2ToObjectModel.xsl 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/src/main/xsl/xmi1.2ToObjectModel.xsl 2009-05-04 12:58:51 UTC (rev 493) @@ -106,6 +106,13 @@ </xsl:with-param> </xsl:call-template> </xsl:for-each> + <xsl:for-each select="UML:Namespace.ownedElement/UML:Enumeration"> + <xsl:call-template name="UMLEnumeration"> + <xsl:with-param name="localPackageName"> + <xsl:value-of select="$localPackageName"/> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> <xsl:apply-templates> <xsl:with-param name="parentLocalPackageName"> <xsl:value-of select="$localPackageNameDot"/> @@ -334,8 +341,33 @@ </xsl:template> + <xsl:template name="UMLEnumeration"> + <xsl:param name="localPackageName"/> + <xsl:element name="enumeration"> + <xsl:attribute name="name"> + <xsl:value-of select="@name" /> + </xsl:attribute> + + <xsl:attribute name="package"> + <xsl:value-of select="$localPackageName"/> + </xsl:attribute> + + <!-- literals --> + <xsl:for-each select="UML:Enumeration.literal/UML:EnumerationLiteral"> + <xsl:element name="literal"> + <xsl:attribute name="name"> + <xsl:value-of select="@name"/> + </xsl:attribute> + </xsl:element> + </xsl:for-each> + + <!-- operations --> + <xsl:for-each select="UML:Classifier.feature/UML:Operation"> + <xsl:call-template name="UMLOperation"/> + </xsl:for-each> + </xsl:element> + </xsl:template> - <xsl:template name="UMLAbstractions"> <xsl:param name="classId"/> <xsl:for-each select="/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/descendant::UML:Abstraction[UML:Dependency.client/UML:Class/@xmi.idref=$classId]"> Modified: eugene/trunk/src/main/xsl/xmi2.1ToObjectModel.xsl =================================================================== --- eugene/trunk/src/main/xsl/xmi2.1ToObjectModel.xsl 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/src/main/xsl/xmi2.1ToObjectModel.xsl 2009-05-04 12:58:51 UTC (rev 493) @@ -260,6 +260,34 @@ </xsl:element> </xsl:template> + <!-- uml:Enumeration --> + <xsl:template match="packagedElement[@xmi:type='uml:Enumeration']"> + <xsl:param name="parentLocalPackageName" /> + <xsl:element name="enumeration"> + <xsl:attribute name="name"> + <xsl:value-of select="@name" /> + </xsl:attribute> + <xsl:attribute name="package"> + <xsl:value-of select="$parentLocalPackageName" /> + </xsl:attribute> + + <!-- literals --> + <xsl:apply-templates select="ownedLiteral" /> + + <!-- operations --> + <xsl:apply-templates select="ownedOperation" /> + + </xsl:element> + </xsl:template> + + <xsl:template match="ownedLiteral"> + <xsl:element name="literal"> + <xsl:attribute name="name"> + <xsl:value-of select="@name" /> + </xsl:attribute> + </xsl:element> + </xsl:template> + <xsl:template match="ownedAttribute"> <xsl:element name="attribute"> @@ -613,6 +641,10 @@ </xsl:when> <xsl:when test="$node[@xmi:type='uml:Enumeration']"> + <xsl:call-template name="fullClassName2"> + <xsl:with-param name="node" + select="$node/ancestor::packagedElement[@xmi:type = 'uml:Package']" /> + </xsl:call-template> <xsl:value-of select="$node/@name" /> </xsl:when> Modified: eugene/trunk/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI12ToObjectModelTest.java =================================================================== --- eugene/trunk/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI12ToObjectModelTest.java 2009-05-04 12:43:02 UTC (rev 492) +++ eugene/trunk/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI12ToObjectModelTest.java 2009-05-04 12:58:51 UTC (rev 493) @@ -40,6 +40,7 @@ import org.junit.Test; import org.nuiton.eugene.models.object.ObjectModelClassifier; import org.nuiton.eugene.models.object.ObjectModelDependency; +import org.nuiton.eugene.models.object.ObjectModelEnumeration; /** * Test de la feuille de style "xmi1.2ToObjectModel.xsl" @@ -151,7 +152,7 @@ } /** - * Apply XSL stylesheet on a argouml model. + * Apply XSL stylesheet on an Argouml model. * And make test on it. * * @throws URISyntaxException @@ -184,4 +185,35 @@ Assert.assertEquals(4,nbDependencies); } + /** + * Apply XSL stylesheet on an Argouml model. + * And make test on it. + * + * @throws URISyntaxException + * @throws IOException + * @throws TransformerException + */ + @Test + public void testXSLEnumeration() throws URISyntaxException, IOException, + TransformerException { + + File xmiFile = new File(Resource.getURL("xmi/1.2/enumeration.xmi") + .toURI()); + + File objectModelFile = transformXMI(xmiFile, "enumeration.objectmodel"); + + ObjectModel model = loadModel(objectModelFile); + + Assert.assertNotNull(model); + Assert.assertEquals("EnumerationTest", model.getName()); + Assert.assertEquals(1, model.getEnumerations().size()); + + for (ObjectModelEnumeration enumeration : model.getEnumerations()) { + // 1 seule énumeration avec 3 literals et 2 opérations + Assert.assertNotNull(enumeration.getQualifiedName()); + Assert.assertEquals(3,enumeration.getLiterals().size()); + Assert.assertEquals(2, enumeration.getOperations().size()); + } + } + } Added: eugene/trunk/src/test/resources/xmi/1.2/enumeration.xmi =================================================================== --- eugene/trunk/src/test/resources/xmi/1.2/enumeration.xmi (rev 0) +++ eugene/trunk/src/test/resources/xmi/1.2/enumeration.xmi 2009-05-04 12:58:51 UTC (rev 493) @@ -0,0 +1,89 @@ +<?xml version = '1.0' encoding = 'UTF-8' ?> +<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Mon May 04 14:18:59 CEST 2009'> + <XMI.header> <XMI.documentation> + <XMI.exporter>ArgoUML (using Netbeans XMI Writer version 1.0)</XMI.exporter> + <XMI.exporterVersion>0.26.2(6) revised on $Date: 2007-05-12 08:08:08 +0200 (Sat, 12 May 2007) $ </XMI.exporterVersion> + </XMI.documentation> + <XMI.metamodel xmi.name="UML" xmi.version="1.4"/></XMI.header> + <XMI.content> + <UML:Model xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EBA' + name = 'EnumerationTest' isSpecification = 'false' isRoot = 'false' isLeaf = 'false' + isAbstract = 'false'> + <UML:Namespace.ownedElement> + <UML:Package xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC5' + name = 'org.test.enums' isSpecification = 'false' isRoot = 'false' isLeaf = 'false' + isAbstract = 'false'> + <UML:Namespace.ownedElement> + <UML:Enumeration xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EBB' + name = 'OneEnumeration' isSpecification = 'false' isRoot = 'false' isLeaf = 'false' + isAbstract = 'false'> + <UML:Classifier.feature> + <UML:Operation xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EBC' + name = 'method1' visibility = 'public' isSpecification = 'false' ownerScope = 'instance' + isQuery = 'true' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false' + isAbstract = 'false'> + <UML:BehavioralFeature.parameter> + <UML:Parameter xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EBD' + name = 'return' isSpecification = 'false' kind = 'return'> + <UML:Parameter.type> + <UML:Class href = 'http://argouml.org/profiles/uml14/default-java.xmi#.:0000000000000859'/> + </UML:Parameter.type> + </UML:Parameter> + </UML:BehavioralFeature.parameter> + </UML:Operation> + <UML:Operation xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EBE' + name = 'method2' visibility = 'public' isSpecification = 'false' ownerScope = 'instance' + isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false' + isAbstract = 'false'> + <UML:BehavioralFeature.parameter> + <UML:Parameter xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EBF' + name = 'return' isSpecification = 'false' kind = 'return'> + <UML:Parameter.type> + <UML:DataType href = 'http://argouml.org/profiles/uml14/default-java.xmi#.:0000000000000873'/> + </UML:Parameter.type> + </UML:Parameter> + <UML:Parameter xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC3' + name = 'param' isSpecification = 'false'> + <UML:Parameter.type> + <UML:Class href = 'http://argouml.org/profiles/uml14/default-java.xmi#.:0000000000000859'/> + </UML:Parameter.type> + </UML:Parameter> + </UML:BehavioralFeature.parameter> + </UML:Operation> + </UML:Classifier.feature> + <UML:Enumeration.literal> + <UML:EnumerationLiteral xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC0' + name = 'LITERAL1' isSpecification = 'false'/> + <UML:EnumerationLiteral xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC1' + name = 'LITERAL2' isSpecification = 'false'/> + <UML:EnumerationLiteral xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC2' + name = 'LITERAL3' isSpecification = 'false'/> + </UML:Enumeration.literal> + </UML:Enumeration> + <UML:Class xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC6' + name = 'TestClass' visibility = 'public' isSpecification = 'false' isRoot = 'false' + isLeaf = 'false' isAbstract = 'false' isActive = 'false'> + <UML:Classifier.feature> + <UML:Attribute xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC7' + name = 'typeEnum' visibility = 'public' isSpecification = 'false' ownerScope = 'instance' + changeability = 'changeable' targetScope = 'instance'> + <UML:StructuralFeature.multiplicity> + <UML:Multiplicity xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC8'> + <UML:Multiplicity.range> + <UML:MultiplicityRange xmi.id = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EC9' + lower = '1' upper = '1'/> + </UML:Multiplicity.range> + </UML:Multiplicity> + </UML:StructuralFeature.multiplicity> + <UML:StructuralFeature.type> + <UML:Enumeration xmi.idref = '-64--88-99-15--134e8b6f:1210ad9bedb:-8000:0000000000000EBB'/> + </UML:StructuralFeature.type> + </UML:Attribute> + </UML:Classifier.feature> + </UML:Class> + </UML:Namespace.ownedElement> + </UML:Package> + </UML:Namespace.ownedElement> + </UML:Model> + </XMI.content> +</XMI>