Index: lutingenerator/src/test/org/codelutin/generator/models/state/project.statemodel
diff -u /dev/null lutingenerator/src/test/org/codelutin/generator/models/state/project.statemodel:1.1
--- /dev/null Fri May 25 16:20:13 2007
+++ lutingenerator/src/test/org/codelutin/generator/models/state/project.statemodel Fri May 25 16:20:08 2007
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: lutingenerator/src/test/org/codelutin/generator/models/state/StateModelTest.java
diff -u /dev/null lutingenerator/src/test/org/codelutin/generator/models/state/StateModelTest.java:1.1
--- /dev/null Fri May 25 16:20:13 2007
+++ lutingenerator/src/test/org/codelutin/generator/models/state/StateModelTest.java Fri May 25 16:20:08 2007
@@ -0,0 +1,145 @@
+/* *##%
+ * Copyright (C) 2007 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.codelutin.generator.models.state;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.generator.models.state.xml.DigesterStateModelRuleSet;
+import org.codelutin.generator.models.state.xml.StateModelImpl;
+import org.xml.sax.SAXException;
+
+/**
+ * StateModelTest.java
+ *
+ * @author chatellier
+ * @version $Revision: 1.1 $
+ *
+ * Last update : $Date: 2007/05/25 16:20:08 $
+ * By : $Author: chatellier $
+ */
+public class StateModelTest extends TestCase {
+
+ /** logger */
+ private static final Log log = LogFactory.getLog(StateModelTest.class);
+
+ /** model */
+ private StateModel stateModel;
+
+ /** init */
+ public void setUp() {
+ Digester d = new Digester();
+ d.addRuleSet(new DigesterStateModelRuleSet());
+
+ stateModel = new StateModelImpl();
+
+ // fin a deplacer
+ try {
+ d.push(stateModel);
+ d.parse(new File("src/test/org/codelutin/generator/models/state/project.statemodel"));
+ d.push(stateModel);
+ stateModel = (StateModel)d.parse(new File("src/test/org/codelutin/generator/models/state/contact.statemodel"));
+ } catch (IOException e) {
+ log.warn("Can't read model file",e);
+ } catch (SAXException e) {
+ log.warn("Can't read model file",e);
+ }
+ }
+
+ /** various test */
+ public void testCorrectStateModel() {
+ List lstChart = stateModel.getStateCharts();
+
+ // trois diagrammes
+ assertTrue(lstChart.size()==3);
+
+ // les 3 ont des états
+ for(StateModelStateChart chart : lstChart) {
+ assertFalse(chart.getStates().isEmpty());
+ }
+
+ // diagramme contactManagementUseCase
+ StateModelStateChart cmChart = null;
+ for(StateModelStateChart smsc : lstChart) {
+ if("contactManagementUseCase".equals(smsc.getName())) {
+ cmChart = smsc;
+ }
+ }
+ assertNotNull(cmChart);
+
+ // package
+ assertEquals(cmChart.getPackageName(),"org.codelutin.chorem.web.contactManagement");
+
+ // six etats
+ Collection lstStates = cmChart.getStates();
+ assertEquals(lstStates.size(),6);
+
+ // le premier etat est initial
+ StateModelState initState = null;
+ StateModelState sfUCState = null;
+ for(StateModelState state : (StateModelState[]) lstStates.toArray(new StateModelState[lstStates.size()])) {
+ if("initContact".equals(state.getName())) {
+ initState = state;
+ }
+ if("societyFormUC".equals(state.getName())) {
+ sfUCState = state;
+ }
+ }
+
+ // test init
+ assertNotNull(initState);
+ assertFalse(initState.isComplex());
+ StateModelSimpleState sInitState = (StateModelSimpleState)initState;
+ assertTrue(sInitState.isInitial());
+
+ // les 3eme etat est complexe et a 4 etat
+ assertNotNull(sfUCState);
+ StateModelComplexState cpxState = (StateModelComplexState)sfUCState;
+ assertEquals(cpxState.getStates().size(),4);
+
+ // test sur un etat
+ Collection lstStatesCpxState = cpxState.getStates();
+ StateModelState sfState = null;
+ for(StateModelState state : (StateModelState[]) lstStatesCpxState.toArray(new StateModelState[lstStatesCpxState.size()])) {
+ if("societyForm".equals(state.getName())) {
+ sfState = state;
+ }
+ }
+ assertNotNull(sfState);
+ assertEquals(sfState.getTransitions().size(), 2);
+
+ // test transition
+ StateModelTransition trEventCancel = null;
+ for(StateModelTransition tr : sfState.getTransitions()) {
+ if("cancel".equals(tr.getEvent())) {
+ trEventCancel = tr;
+ }
+ }
+ assertNotNull(trEventCancel);
+ assertNotNull(trEventCancel.getDestinationState());
+ assertEquals(trEventCancel.getDestinationState().getName(), "finalSocietyFormCancel");
+ }
+}
Index: lutingenerator/src/test/org/codelutin/generator/models/state/contact.statemodel
diff -u /dev/null lutingenerator/src/test/org/codelutin/generator/models/state/contact.statemodel:1.1
--- /dev/null Fri May 25 16:20:14 2007
+++ lutingenerator/src/test/org/codelutin/generator/models/state/contact.statemodel Fri May 25 16:20:08 2007
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+