Source Code Cross Referenced for ProjectSessionTests.java in  » Workflow-Engines » bonita-v3.1 » hero » client » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » bonita v3.1 » hero.client.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package hero.client.test;
0002:
0003:        /*
0004:         *
0005:         * NodeTests.java - 
0006:         * Copyright (C) 2002 Ecoo Team
0007:         * charoy@loria.fr
0008:         *
0009:         *
0010:         * This program is free software; you can redistribute it and/or
0011:         * modify it under the terms of the GNU Lesser General Public License
0012:         * as published by the Free Software Foundation; either version 2
0013:         * of the License, or (at your option) any later version.
0014:         *
0015:         * This program is distributed in the hope that it will be useful,
0016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018:         * GNU Lesser General Public License for more details.
0019:         *
0020:         * You should have received a copy of the GNU Lesser General Public License
0021:         * along with this program; if not, write to the Free Software
0022:         * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0023:         */
0024:
0025:        import hero.interfaces.BnEdgeValue;
0026:        import hero.interfaces.BnRoleMapperValue;
0027:        import hero.interfaces.BnNodePropertyValue;
0028:        import hero.interfaces.BnNodeValue;
0029:        import hero.interfaces.BnProjectHome;
0030:        import hero.interfaces.BnProjectPropertyValue;
0031:        import hero.interfaces.BnProjectValue;
0032:        import hero.interfaces.BnUser;
0033:        import hero.interfaces.BnUserHome;
0034:        import hero.interfaces.BnUserLightValue;
0035:        import hero.interfaces.BnUserUtil;
0036:        import hero.interfaces.BnUserValue;
0037:        import hero.interfaces.Constants;
0038:        import hero.interfaces.ProjectSession;
0039:        import hero.interfaces.ProjectSessionHome;
0040:        import hero.interfaces.ProjectSessionUtil;
0041:        import hero.interfaces.UserSession;
0042:        import hero.interfaces.UserSessionHome;
0043:        import hero.interfaces.UserSessionUtil;
0044:        import hero.util.DuplicatedEdgeException;
0045:        import hero.util.EventConstants;
0046:        import hero.util.HeroException;
0047:
0048:        import java.util.ArrayList;
0049:        import java.util.Collection;
0050:        import java.util.Iterator;
0051:
0052:        import junit.framework.TestCase;
0053:        import junit.framework.TestSuite;
0054:
0055:        public class ProjectSessionTests extends TestCase {
0056:            private BnProjectHome projecth;
0057:            private ProjectSessionHome projectSessionh;
0058:
0059:            public ProjectSessionTests(String testname) {
0060:                super (testname);
0061:            }
0062:
0063:            public static TestSuite suite() {
0064:                return new TestSuite(ProjectSessionTests.class);
0065:            }
0066:
0067:            public void setUp() throws Exception {
0068:            }
0069:
0070:            public void testCreateProjectSession() throws Exception {
0071:                ProjectSessionHome lHome = ProjectSessionUtil.getHome();
0072:                ProjectSession lProject = lHome.create();
0073:                lProject.initProject("projectsession");
0074:                BnProjectValue pv = lProject.getDetails();
0075:                BnUserLightValue[] uv = pv.getBnUsers();
0076:                int i = 0;
0077:                while (i < uv.length) {
0078:                    if (uv[i].getName().equals("admin"))
0079:                        break;
0080:                    i++;
0081:                }
0082:                assertTrue("Admin is in the projet", i < uv.length);
0083:            }
0084:
0085:            public void testCloneProjectSession() throws Exception {
0086:                ProjectSessionHome lHome = ProjectSessionUtil.getHome();
0087:                ProjectSession lProject = lHome.create();
0088:                lProject.initProject("projectsource");
0089:                lProject.addNode("nclone", Constants.Nd.AND_JOIN_NODE);
0090:                lProject.addNode("c1", Constants.Nd.AND_JOIN_NODE);
0091:                lProject.addNode("c2", Constants.Nd.AND_JOIN_NODE);
0092:                lProject.setNodeRole("nclone", "admin");
0093:                lProject.setNodeRole("c1", "admin");
0094:                lProject.setNodeRole("c2", "admin");
0095:                String edge1 = lProject.addEdge("c1", "c2");
0096:                lProject = lHome.create();
0097:                lProject.initProject("projectsource", "tralara");
0098:                BnProjectValue pv = lProject.getDetails();
0099:                assertTrue("Clone failure1", pv.getBnNodes().length == 3);
0100:                assertTrue("Clone failure2", pv.getName().equalsIgnoreCase(
0101:                        "tralara"));
0102:            }
0103:
0104:            public void testImportProject() throws Exception {
0105:                ProjectSessionHome lHome = ProjectSessionUtil.getHome();
0106:                ProjectSession lProject = lHome.create();
0107:                lProject.initProject("projectS");
0108:                lProject.addNode("nclone", Constants.Nd.AND_JOIN_NODE);
0109:                lProject.addNode("c1", Constants.Nd.AND_JOIN_NODE);
0110:                lProject.addNode("c2", Constants.Nd.AND_JOIN_NODE);
0111:                lProject.setNodeRole("nclone", "admin");
0112:                lProject.setNodeRole("c1", "admin");
0113:                lProject.setNodeRole("c2", "admin");
0114:                String edge1 = lProject.addEdge("c1", "c2");
0115:
0116:                lProject = lHome.create();
0117:                lProject.initProject("pDest");
0118:
0119:                lProject.addNode("nclone2", Constants.Nd.AND_JOIN_NODE);
0120:                lProject.setNodeRole("nclone2", "admin");
0121:                lProject.importProject("projectS",
0122:                        EventConstants.DEFAULTPROJECTVERSION, "pDest");
0123:                BnProjectValue pv = lProject.getDetails();
0124:                assertTrue("Clone failure1", pv.getBnNodes().length == 4);
0125:                assertTrue("Clone failure2", pv.getName().equalsIgnoreCase(
0126:                        "pDest"));
0127:            }
0128:
0129:            public void testAddUserToProject() throws Exception {
0130:                ProjectSessionHome lHome = ProjectSessionUtil.getHome();
0131:                ProjectSession lProject = lHome.create();
0132:                lProject.initProject("projectadduser");
0133:                BnUserHome uHome = BnUserUtil.getHome();
0134:                BnUserValue pdata = new BnUserValue();
0135:                pdata.setName("bidochon");
0136:                pdata.setPassword("bidochon");
0137:                pdata.setEmail("bidochon@loria.fr");
0138:                BnUser lUser = uHome.create(pdata);
0139:                lProject.addUser("bidochon");
0140:                pdata.setName("marcel");
0141:                pdata.setPassword("marcel");
0142:                pdata.setEmail("marcel@loria.fr");
0143:                lUser = uHome.create(pdata);
0144:                lProject.addUser("marcel");
0145:                pdata.setName("germaine");
0146:                pdata.setPassword("germaine");
0147:                pdata.setEmail("germaine@loria.fr");
0148:                lUser = uHome.create(pdata);
0149:                lProject.addUser("germaine");
0150:                assertTrue(lProject.containsUser("bidochon"));
0151:            }
0152:
0153:            public void testAddNodeToProject() throws Exception {
0154:                ProjectSessionHome lHome = ProjectSessionUtil.getHome();
0155:                ProjectSession lProject = lHome.create();
0156:                lProject.initProject("projectaddnode");
0157:                lProject.addNode("thenode", 1);
0158:                BnNodeValue nv = lProject.getNodeValue("thenode");
0159:                assertTrue("Creator not correctly set", nv.getCreator().equals(
0160:                        "admin"));
0161:            }
0162:
0163:            public void testAddEdgeToProject() throws Exception {
0164:                ProjectSessionHome lHome = ProjectSessionUtil.getHome();
0165:                ProjectSession lProject = lHome.create();
0166:                lProject.initProject("projectaddedge");
0167:                lProject.addNode("thenode", Constants.Nd.AND_JOIN_NODE);
0168:                lProject.addNode("thenode2", Constants.Nd.AND_JOIN_NODE);
0169:                String ename = lProject.addEdge("thenode", "thenode2");
0170:                BnEdgeValue ev = lProject.getEdgeValue(ename);
0171:                BnNodeValue nv = lProject.getNodeValue("thenode2");
0172:                assertTrue("addEdge failed a1",
0173:                        ev.getState() == Constants.Ed.INITIAL);
0174:                assertTrue("bad node state test3",
0175:                        nv.getState() == Constants.Nd.INITIAL);
0176:            }
0177:
0178:            public void testProjectSessionAddUser() throws Exception {
0179:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0180:                        .getHome();
0181:                ProjectSession pss = projectSessionh.create();
0182:                pss.initProject("pst");
0183:
0184:                try {
0185:                    pss.addUser("badUser");
0186:                    assertTrue("Should have throw EJBException", false);
0187:                } catch (Exception e) {
0188:                    //expected behavior
0189:                }
0190:            }
0191:
0192:            public void testProjectSessionAddNode() throws Exception {
0193:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0194:                        .getHome();
0195:                ProjectSession pss = projectSessionh.create();
0196:                pss.initProject("pst2");
0197:                pss.addNode("test", Constants.Nd.AND_JOIN_NODE);
0198:                BnNodeValue pv = pss.getNodeValue("test");
0199:
0200:                assertTrue("Creator not correctly set", pv.getCreator().equals(
0201:                        "admin"));
0202:            }
0203:
0204:            public void testProjectSessionAddEdgesState() throws Exception {
0205:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0206:                        .getHome();
0207:                ProjectSession pss = projectSessionh.create();
0208:                pss.initProject("w");
0209:
0210:                pss.addNode("node1", Constants.Nd.AND_JOIN_NODE);
0211:                pss.addNode("node2", Constants.Nd.AND_JOIN_NODE);
0212:                pss.addNode("node3", Constants.Nd.AND_JOIN_NODE);
0213:                String edname = pss.addEdge("node1", "node2");
0214:                BnEdgeValue ev = pss.getEdgeValue(edname);
0215:                BnNodeValue nv = pss.getNodeValue("node2");
0216:                assertTrue("addEdge failed a1",
0217:                        ev.getState() == Constants.Ed.INITIAL);
0218:                assertTrue("addEdge failed a1/n2",
0219:                        nv.getState() == Constants.Nd.INITIAL);
0220:                edname = pss.addEdge("node2", "node3");
0221:                ev = pss.getEdgeValue(edname);
0222:                BnNodeValue nv2 = pss.getNodeValue("node2");
0223:                BnNodeValue nv3 = pss.getNodeValue("node3");
0224:                assertTrue("addEdge failed a2",
0225:                        ev.getState() == Constants.Ed.INITIAL);
0226:                assertTrue("addEdge failed a2/nv2",
0227:                        nv2.getState() == Constants.Nd.INITIAL);
0228:                assertTrue("addEdge failed a2/nv3",
0229:                        nv3.getState() == Constants.Nd.INITIAL);
0230:            }
0231:
0232:            public void testcheckDuplicateEdge() throws Exception {
0233:
0234:                try {
0235:                    ProjectSessionHome projectSessionh = ProjectSessionUtil
0236:                            .getHome();
0237:                    ProjectSession pss = projectSessionh.create();
0238:                    pss.initProject("wde");
0239:
0240:                    pss.addNode("node1", Constants.Nd.AND_JOIN_NODE);
0241:                    pss.addNode("node2", Constants.Nd.AND_JOIN_NODE);
0242:                    pss.addEdge("node1", "node2");
0243:
0244:                    pss.addNode("node3", Constants.Nd.AND_JOIN_NODE);
0245:                    pss.addEdge("node2", "node3");
0246:
0247:                    pss.addNode("node4", Constants.Nd.AND_JOIN_NODE);
0248:                    pss.addEdge("node1", "node4");
0249:
0250:                    pss.addEdge("node1", "node2");
0251:                    assertTrue("Should have thrown a DuplicatedEdgeException",
0252:                            false);
0253:                } catch (DuplicatedEdgeException e) {
0254:                }
0255:            }
0256:
0257:            public void testDynamicProject() throws Exception {
0258:                UserSessionHome usersh = UserSessionUtil.getHome();
0259:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0260:                        .getHome();
0261:                ProjectSession pss = projectSessionh.create();
0262:                pss.initProject("dynamic");
0263:
0264:                pss.addNode("n1", Constants.Nd.AND_JOIN_NODE);
0265:                pss.addNode("n2", Constants.Nd.AND_JOIN_NODE);
0266:                pss.addEdge("n1", "n2");
0267:                pss.setNodeRole("n1", "admin");
0268:                pss.setNodeRole("n1", "admin");
0269:
0270:                UserSession usr = usersh.create();
0271:
0272:                usr.startActivity("dynamic", "n1");
0273:
0274:                pss.addNode("n3", Constants.Nd.AND_JOIN_NODE);
0275:                String edge2 = pss.addEdge("n2", "n3");
0276:
0277:                assertTrue("dynamic change failed - n1", pss.getNodeValue("n1")
0278:                        .getState() == Constants.Nd.EXECUTING);
0279:                assertTrue("dynamic change failed - n2", pss.getNodeValue("n2")
0280:                        .getState() == Constants.Nd.ANTICIPABLE);
0281:                assertTrue("dynamic change failed - n3", pss.getNodeValue("n3")
0282:                        .getState() == Constants.Nd.INITIAL);
0283:
0284:                usr.startActivity("dynamic", "n2");
0285:
0286:                assertTrue("dynamic change failed - n1.1", pss.getNodeValue(
0287:                        "n1").getState() == Constants.Nd.EXECUTING);
0288:                assertTrue("dynamic change failed - n2.1", pss.getNodeValue(
0289:                        "n2").getState() == Constants.Nd.ANTICIPATING);
0290:                assertTrue("dynamic change failed - n3.1", pss.getNodeValue(
0291:                        "n3").getState() == Constants.Nd.ANTICIPABLE);
0292:
0293:                pss.deleteEdge(edge2);
0294:
0295:                assertTrue("dynamic change failed - n1.2", pss.getNodeValue(
0296:                        "n1").getState() == Constants.Nd.EXECUTING);
0297:                assertTrue("dynamic change failed - n2.2", pss.getNodeValue(
0298:                        "n2").getState() == Constants.Nd.ANTICIPATING);
0299:                assertTrue("dynamic change failed - n3.2", pss.getNodeValue(
0300:                        "n3").getState() == Constants.Nd.READY);
0301:
0302:                pss.addEdge("n2", "n3");
0303:
0304:                assertTrue("dynamic change failed - n1.3", pss.getNodeValue(
0305:                        "n1").getState() == Constants.Nd.EXECUTING);
0306:                assertTrue("dynamic change failed - n2.3", pss.getNodeValue(
0307:                        "n2").getState() == Constants.Nd.ANTICIPATING);
0308:                assertTrue("dynamic change failed - n3.3", pss.getNodeValue(
0309:                        "n3").getState() == Constants.Nd.ANTICIPABLE);
0310:
0311:            }
0312:
0313:            public void TestDynamicProject2() throws Exception {
0314:                UserSessionHome usersh = UserSessionUtil.getHome();
0315:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0316:                        .getHome();
0317:
0318:                ProjectSession pss = projectSessionh.create();
0319:                pss.initProject("dynamic2");
0320:
0321:                pss.addNode("n1", Constants.Nd.AND_JOIN_NODE);
0322:                pss.addNode("n2", Constants.Nd.AND_JOIN_NODE);
0323:                String edge1 = pss.addEdge("n1", "n2");
0324:                pss.setNodeRole("n1", "admin");
0325:                pss.setNodeRole("n2", "admin");
0326:
0327:                UserSession usr = usersh.create();
0328:
0329:                usr.startActivity("dynamic2", "n1");
0330:
0331:                pss.addNode("n3", Constants.Nd.AND_JOIN_NODE);
0332:                pss.addEdge("n2", "n3");
0333:
0334:                assertTrue("dynamic change failed - n1", pss.getEdgeValue("n1")
0335:                        .getState() == Constants.Nd.EXECUTING);
0336:                assertTrue("dynamic change failed - n2", pss.getEdgeValue("n2")
0337:                        .getState() == Constants.Nd.ANTICIPABLE);
0338:                assertTrue("dynamic change failed - n3", pss.getEdgeValue("n3")
0339:                        .getState() == Constants.Nd.INITIAL);
0340:
0341:                pss.addNode("n4", Constants.Nd.AND_JOIN_NODE);
0342:                pss.addEdge("n1", "n4");
0343:                pss.deleteEdge(edge1);
0344:
0345:                assertTrue("dynamic change failed - n1.1", pss.getEdgeValue(
0346:                        "n1").getState() == Constants.Nd.EXECUTING);
0347:                assertTrue("dynamic change failed - n2.1", pss.getEdgeValue(
0348:                        "n2").getState() == Constants.Nd.READY);
0349:                assertTrue("dynamic change failed - n3.1", pss.getEdgeValue(
0350:                        "n3").getState() == Constants.Nd.INITIAL);
0351:                assertTrue("dynamic change failed - n4.1", pss.getEdgeValue(
0352:                        "n4").getState() == Constants.Nd.ANTICIPABLE);
0353:            }
0354:
0355:            public void testDeleteNode() throws Exception {
0356:                UserSessionHome usersh = UserSessionUtil.getHome();
0357:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0358:                        .getHome();
0359:
0360:                ProjectSession pss = projectSessionh.create();
0361:                pss.initProject("deleteNode");
0362:
0363:                pss.addNode("n1", Constants.Nd.AND_JOIN_NODE);
0364:                pss.addNode("n2", Constants.Nd.AND_JOIN_NODE);
0365:                String edge1 = pss.addEdge("n1", "n2");
0366:                pss.setNodeRole("n1", "admin");
0367:                pss.setNodeRole("n2", "admin");
0368:
0369:                try {
0370:                    pss.deleteNode("n2");
0371:                } catch (HeroException he) {
0372:                    assertTrue("Deletion Failed", false);
0373:                }
0374:
0375:                UserSession usr = usersh.create();
0376:
0377:                usr.startActivity("deleteNode", "n1");
0378:                try {
0379:                    pss.deleteNode("n1");
0380:                    assertTrue("Deletion Should have Failed", false);
0381:                } catch (HeroException he) { // Normal Behavior
0382:                }
0383:            }
0384:
0385:            public void testPropertyNode() throws Exception {
0386:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0387:                        .getHome();
0388:
0389:                ProjectSession pss = projectSessionh.create();
0390:                pss.initProject("propertyNode");
0391:
0392:                pss.addNode("n1", Constants.Nd.AND_JOIN_NODE);
0393:                pss.addNode("n2", Constants.Nd.AND_JOIN_NODE);
0394:                String edge1 = pss.addEdge("n1", "n2");
0395:                pss.setNodeRole("n1", "admin");
0396:                pss.setNodeRole("n2", "admin");
0397:                pss.setNodeProperty("n1", "kpn1", "vpn1");
0398:                pss.setNodeProperty("n2", "kpn2", "vpn2");
0399:                pss.setNodeProperty("n2", "kpn2", "vpn22");
0400:
0401:                pss.deleteNode("n2");
0402:
0403:            }
0404:
0405:            public void testDeletePropertyNode() throws Exception {
0406:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0407:                        .getHome();
0408:                ProjectSession pss = projectSessionh.create();
0409:                pss.initProject("propertyNode");
0410:
0411:                pss.deleteNodeProperty("n1", "kpn1");
0412:
0413:            }
0414:
0415:            public void testPropertyProject() throws Exception {
0416:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0417:                        .getHome();
0418:                ProjectSession pss = projectSessionh.create();
0419:                pss.initProject("propertyNode");
0420:
0421:                pss.setProperty("maintenant", "ara");
0422:                pss.setProperty("deja", "ahora");
0423:                pss.setProperty("deja", "ja");
0424:
0425:            }
0426:
0427:            public void testDeletePropertyProject() throws Exception {
0428:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0429:                        .getHome();
0430:                ProjectSession pss = projectSessionh.create();
0431:                pss.initProject("propertyNode");
0432:
0433:                pss.deleteProperty("maintenant");
0434:            }
0435:
0436:            public void testNodePropertyPropagate() throws Exception {
0437:                UserSessionHome usersh = UserSessionUtil.getHome();
0438:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0439:                        .getHome();
0440:                ProjectSession pss = projectSessionh.create();
0441:                pss.initProject("propertyNode");
0442:
0443:                pss.addNode("n5", Constants.Nd.AND_JOIN_NODE);
0444:                pss.addNode("n6", Constants.Nd.AND_JOIN_NODE);
0445:                String edge1 = pss.addEdge("n5", "n6");
0446:                pss.setNodeRole("n5", "admin");
0447:                pss.setNodeRole("n6", "admin");
0448:                pss.setNodeProperty("n5", "value", "15");
0449:                pss.setNodeProperty("n5", "value2", "10");
0450:                pss.setNodeProperty("n6", "value", "25");
0451:
0452:                UserSession usr = usersh.create();
0453:                usr.startActivity("propertyNode", "n5");
0454:                usr.terminateActivity("propertyNode", "n5");
0455:            }
0456:
0457:            public void testGetPropertiesNode() throws Exception {
0458:
0459:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0460:                        .getHome();
0461:                ProjectSession pss = projectSessionh.create();
0462:                pss.initProject("propertyNode");
0463:
0464:                pss.addNode("p1", Constants.Nd.AND_JOIN_NODE);
0465:
0466:                pss.setNodeProperty("p1", "k1", "10");
0467:
0468:                Collection c = pss.getNodeProperties("p1");
0469:
0470:                for (Iterator i = c.iterator(); i.hasNext();) {
0471:                    BnNodePropertyValue p = (BnNodePropertyValue) i.next();
0472:                    String key = p.getTheKey();
0473:                    String value = p.getTheValue();
0474:                    assertTrue("Get BnNode Properties", key
0475:                            .equalsIgnoreCase("k1"));
0476:
0477:                }
0478:            }
0479:
0480:            public void testGetProperties() throws Exception {
0481:
0482:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0483:                        .getHome();
0484:                ProjectSession pss = projectSessionh.create();
0485:                pss.initProject("propertyNode");
0486:
0487:                pss.setProperty("pk1", "xxx");
0488:
0489:                Collection c = pss.getProperties();
0490:
0491:                for (Iterator i = c.iterator(); i.hasNext();) {
0492:                    BnProjectPropertyValue p = (BnProjectPropertyValue) i
0493:                            .next();
0494:                    String key = p.getTheKey();
0495:                    String value = p.getTheValue();
0496:                    if (value.equals("xxx"))
0497:                        assertTrue("Get Properties", key.equals("pk1"));
0498:                }
0499:            }
0500:
0501:            public void testNodeDeadline() throws Exception {
0502:
0503:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0504:                        .getHome();
0505:                ProjectSession pss = projectSessionh.create();
0506:                pss.initProject("deadlineNode");
0507:
0508:                pss.addNode("d1", Constants.Nd.AND_JOIN_NODE);
0509:                pss.setNodeRole("d1", "admin");
0510:                pss.setNodeDeadline("d1", System.currentTimeMillis()
0511:                        + (long) 10000);
0512:            }
0513:
0514:            public void testJavaHook() throws Exception {
0515:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0516:                        .getHome();
0517:                UserSessionHome usersh = UserSessionUtil.getHome();
0518:                UserSession usr = usersh.create();
0519:                ProjectSession pss = projectSessionh.create();
0520:                pss.initProject("hookProject");
0521:                pss.addNode("h2", Constants.Nd.AND_JOIN_NODE);
0522:                pss.setNodeRole("h2", "admin");
0523:                pss.addNode("h1", Constants.Nd.AND_JOIN_NODE);
0524:                pss.addNodeHook("h1", "hero.hook.TestHook",
0525:                        hero.interfaces.Constants.Nd.AFTERSTART,
0526:                        Constants.Hook.JAVA);
0527:                pss.setNodeRole("h1", "admin");
0528:
0529:                usr.startActivity("hookProject", "h1");
0530:                usr.terminateActivity("hookProject", "h1");
0531:                usr.startActivity("hookProject", "h2");
0532:                pss.deleteNodeHook("h1", "hero.hook.TestHook");
0533:                usr.terminateActivity("hookProject", "h2");
0534:
0535:            }
0536:
0537:            public void testJavaHookInstance() throws Exception {
0538:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0539:                        .getHome();
0540:                UserSessionHome usersh = UserSessionUtil.getHome();
0541:                UserSession usr = usersh.create();
0542:                ProjectSession pss = projectSessionh.create();
0543:                pss.initModel("hookProjectInst");
0544:                pss.addNode("h2", Constants.Nd.AND_JOIN_NODE);
0545:                pss.setNodeRole("h2", "admin");
0546:                pss.addNode("h1", Constants.Nd.AND_JOIN_NODE);
0547:                pss.addNodeHook("h1", "hero.hook.TestHook",
0548:                        hero.interfaces.Constants.Nd.AFTERSTART,
0549:                        Constants.Hook.JAVA);
0550:                pss.setNodeRole("h1", "admin");
0551:
0552:                String instName = pss.instantiateProject("hookProjectInst");
0553:
0554:                usr.startActivity(instName, "h1");
0555:                usr.terminateActivity(instName, "h1");
0556:                usr.startActivity(instName, "h2");
0557:                usr.terminateActivity(instName, "h2");
0558:            }
0559:
0560:            public void testProjectJavaHook() throws Exception {
0561:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0562:                        .getHome();
0563:                UserSessionHome usersh = UserSessionUtil.getHome();
0564:                UserSession usr = usersh.create();
0565:                ProjectSession pss = projectSessionh.create();
0566:                pss.initModel("ProjectJavahook");
0567:                pss.addNode("h1", Constants.Nd.AND_JOIN_NODE);
0568:                pss.addNode("h2", Constants.Nd.AND_JOIN_NODE);
0569:                pss.addEdge("h1", "h2");
0570:                pss.addHook("hero.hook.TestProcessHook",
0571:                        hero.interfaces.Constants.Pj.ONINSTANTIATE,
0572:                        Constants.Hook.JAVA);
0573:                pss.instantiateProject("ProjectJavahook");
0574:            }
0575:
0576:            public void testNodeInterHook() throws Exception {
0577:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0578:                        .getHome();
0579:                UserSessionHome usersh = UserSessionUtil.getHome();
0580:                UserSession usr = usersh.create();
0581:                ProjectSession pss = projectSessionh.create();
0582:                pss.initProject("hookInterNode");
0583:                pss.addNode("h2", Constants.Nd.AND_JOIN_NODE);
0584:                pss.setNodeRole("h2", "admin");
0585:                pss.addNode("h1", Constants.Nd.AND_JOIN_NODE);
0586:                pss.setNodeRole("h1", "admin");
0587:                String edge1 = pss.addEdge("h1", "h2");
0588:                String script = "import hero.interfaces.BnProjectLocal;\n"
0589:                        + "import hero.interfaces.BnNodeLocal;\n"
0590:                        + "afterStart (Object b,Object n) {\n\n\n"
0591:                        + "System.out.println(\"InteractiveBnNodee Hook test, node: \"+n.getName());"
0592:                        + "}";
0593:                pss.addNodeInterHook("h1", "interTest",
0594:                        hero.interfaces.Constants.Nd.AFTERSTART,
0595:                        Constants.Hook.BSINTERACTIVE, script);
0596:                usr.startActivity("hookInterNode", "h1");
0597:                usr.terminateActivity("hookInterNode", "h1");
0598:            }
0599:
0600:            public void testNodeInterHookProperty() throws Exception {
0601:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0602:                        .getHome();
0603:                UserSessionHome usersh = UserSessionUtil.getHome();
0604:                UserSession usr = usersh.create();
0605:                ProjectSession pss = projectSessionh.create();
0606:                pss.initProject("hookInterNodeP");
0607:                pss.addNode("h2", Constants.Nd.AND_JOIN_NODE);
0608:                pss.setNodeRole("h2", "admin");
0609:                pss.addNode("h1", Constants.Nd.AND_JOIN_NODE);
0610:                pss.setNodeProperty("h1", "testp1", "testv1", true);
0611:                pss.setNodeProperty("h1", "testp2", "testv2", true);
0612:                pss.setNodeRole("h1", "admin");
0613:                String edge1 = pss.addEdge("h1", "h2");
0614:                String script = "import hero.interfaces.BnProjectLocal;\n"
0615:                        + "import hero.interfaces.BnNodeLocal;\n"
0616:                        + "afterStart (Object b,Object n) {\n\n\n"
0617:                        + "System.out.println(\"InteractiveBnNodee Hook properties tests, node: \"+n.getName());\n"
0618:                        + "System.out.println(\"property \"+testp2);\n" + "}";
0619:                pss.addNodeInterHook("h1", "interTest",
0620:                        hero.interfaces.Constants.Nd.AFTERSTART,
0621:                        Constants.Hook.BSINTERACTIVE, script);
0622:                usr.startActivity("hookInterNodeP", "h1");
0623:                usr.terminateActivity("hookInterNodeP", "h1");
0624:            }
0625:
0626:            public void testProjectInterHook() throws Exception {
0627:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0628:                        .getHome();
0629:                UserSessionHome usersh = UserSessionUtil.getHome();
0630:                UserSession usr = usersh.create();
0631:                ProjectSession pss = projectSessionh.create();
0632:                pss.initProject("hookInterProject");
0633:                pss.addNode("h2", Constants.Nd.AND_JOIN_NODE);
0634:                pss.setNodeRole("h2", "admin");
0635:                pss.addNode("h1", Constants.Nd.AND_JOIN_NODE);
0636:                pss.setNodeRole("h1", "admin");
0637:                String edge1 = pss.addEdge("h1", "h2");
0638:                String script = "import hero.interfaces.BnProjectLocal;\n"
0639:                        + "import hero.interfaces.BnNodeLocal;\n"
0640:                        + "afterStart (Object b,Object n) {\n\n\n"
0641:                        + "System.out.println(\"InteractiveBnProjectt Hook test, node: \"+n.getName());"
0642:                        + "}";
0643:                pss.addInterHook("projectInterTest",
0644:                        hero.interfaces.Constants.Nd.AFTERSTART,
0645:                        Constants.Hook.BSINTERACTIVE, script);
0646:                usr.startActivity("hookInterProject", "h1");
0647:                usr.terminateActivity("hookInterProject", "h1");
0648:            }
0649:
0650:            public void testDuplicatedInterHook() throws Exception {
0651:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0652:                        .getHome();
0653:                UserSessionHome usersh = UserSessionUtil.getHome();
0654:                UserSession usr = usersh.create();
0655:                ProjectSession pss = projectSessionh.create();
0656:                pss.initProject("dupliHookInter");
0657:                pss.addNode("h2", Constants.Nd.AND_JOIN_NODE);
0658:                pss.setNodeRole("h2", "admin");
0659:                pss.addNode("h1", Constants.Nd.AND_JOIN_NODE);
0660:                pss.setNodeRole("h1", "admin");
0661:                String edge1 = pss.addEdge("h1", "h2");
0662:                String script = "import hero.interfaces.BnProjectLocal;\n"
0663:                        + "import hero.interfaces.BnNodeLocal;\n"
0664:                        + "afterStart (Object b,Object n) {\n\n\n"
0665:                        + "System.out.println(\"InteractiveBnProjectt Hook test, node: \"+n.getName()+\" project: \"+(n.getBnProject()).getName());"
0666:                        + "}";
0667:                pss.addInterHook("projectInterTest",
0668:                        hero.interfaces.Constants.Nd.AFTERSTART,
0669:                        Constants.Hook.BSINTERACTIVE, script);
0670:                try {
0671:                    pss.addInterHook("projectInterTest",
0672:                            hero.interfaces.Constants.Nd.AFTERSTART,
0673:                            Constants.Hook.BSINTERACTIVE, script);
0674:                    assertTrue("should have failed", false);
0675:                } catch (HeroException h) {
0676:                    // normal behavior
0677:                }
0678:                usr.startActivity("dupliHookInter", "h1");
0679:                usr.terminateActivity("dupliHookInter", "h1");
0680:            }
0681:
0682:            public void testSubProcess() throws Exception {
0683:
0684:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0685:                        .getHome();
0686:                ProjectSession pss = projectSessionh.create();
0687:                pss.initProject("SubProject");
0688:                pss.addNode("subNode1", Constants.Nd.AND_JOIN_NODE);
0689:                pss.addNode("subNode2", Constants.Nd.AND_JOIN_NODE);
0690:                pss.addRoleMapper("InitialRole", "mapper1",
0691:                        Constants.Mapper.PROPERTIES);
0692:                pss.addEdge("subNode1", "subNode2");
0693:
0694:                ProjectSession pss1 = projectSessionh.create();
0695:                pss1 = projectSessionh.create();
0696:                pss1.initProject("ParentProject");
0697:                pss1.addRoleMapper("InitialRole", "mapper1",
0698:                        Constants.Mapper.PROPERTIES);
0699:                pss1.addNode("node1", Constants.Nd.AND_JOIN_NODE);
0700:                pss1.addNode("node2", Constants.Nd.AND_JOIN_NODE);
0701:                pss1.addNodeSubProcess("nodeSub", "SubProject");
0702:                pss1.addEdge("node1", "nodeSub");
0703:                pss1.addEdge("nodeSub", "node2");
0704:
0705:                UserSessionHome usersh = UserSessionUtil.getHome();
0706:                UserSession usr = usersh.create();
0707:                usr.startActivity("ParentProject", "node1");
0708:                usr.terminateActivity("ParentProject", "node1");
0709:
0710:                assertTrue("SubProcess Error",
0711:                        pss1.getNodeState("nodeSub") == Constants.Nd.EXECUTING);
0712:
0713:                // Terminate all SubProcess activities
0714:
0715:                usr.startActivity("SubProject", "subNode1");
0716:                usr.startActivity("SubProject", "subNode2");
0717:                usr.terminateActivity("SubProject", "subNode1");
0718:                usr.terminateActivity("SubProject", "subNode2");
0719:                assertTrue("SubProcess Error 3",
0720:                        pss1.getNodeState("nodeSub") == Constants.Nd.TERMINATED);
0721:            }
0722:
0723:            /*public void testSimpleInstantiation() throws Exception {
0724:
0725:              ProjectSessionHome projectSessionh=ProjectSessionUtil.getHome();
0726:              ProjectSession pss = projectSessionh.create();
0727:              pss.initModel("Instantiation");
0728:              pss.addNode("node1",Constants.Nd.AND_JOIN_NODE);
0729:              pss.addNode("node2",Constants.Nd.AND_JOIN_NODE);
0730:              pss.addNode("node3",Constants.Nd.AND_JOIN_NODE);
0731:              pss.addNode("node4",Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
0732:              pss.addEdge("node1","node2");
0733:              pss.addEdge("node2","node3");
0734:              pss.addEdge("node2","node4");
0735:              String script =
0736:            		"import hero.interfaces.BnProjectLocal;\n"
0737:            		+ "import hero.interfaces.BnNodeLocal;\n"
0738:            		+ "afterStart (Object b,Object n) {\n\n\n"
0739:            		+ "System.out.println(\"Instantiation test, node: \"+n.getName()+\" project: \"+(n.getBnProject()).getName());"
0740:            		+ "}";
0741:              pss.addNodeInterHook("node2","node2",hero.interfaces.Constants.Nd.AFTERSTART,Constants.Hook.BSINTERACTIVE,script);
0742:              pss.addUser("admin2");
0743:              pss.setUserRole("admin2","InitialRole");
0744:              pss.setNodeRole("node1","admin");
0745:              
0746:              ProjectSession pss1 = projectSessionh.create();	  
0747:              String instName=pss1.instantiateProject("Instantiation");
0748:              assertTrue("Instantiation Error, instance name error", pss1.getName().equals(instName));
0749:              assertTrue("Instantiation Error, role error in node1", pss1.getNodeRoleName("node1").equals("admin"));
0750:              Collection users = pss1.getUsers();
0751:              assertTrue("Instantiation Error, user admin2 does not exist", users.contains("admin2"));
0752:              assertTrue("Instantiation Error, type error in node1", pss1.getNodeType("node1")== Constants.Nd.AND_JOIN_NODE);	  
0753:            }
0754:            
0755:            public void testSubProcessInstantiation() throws Exception {
0756:
0757:              ProjectSessionHome projectSessionh=ProjectSessionUtil.getHome();
0758:              
0759:              ProjectSession psSub = projectSessionh.create();
0760:              psSub.initProject("node5");
0761:              psSub.addNode("subNode1",Constants.Nd.AND_JOIN_NODE);
0762:              psSub.addNode("subNode2",Constants.Nd.AND_JOIN_NODE);
0763:              psSub.addEdge("subNode1","subNode2");
0764:              
0765:              String script =
0766:            		"import hero.interfaces.BnProjectLocal;\n"
0767:            		+ "import hero.interfaces.BnNodeLocal;\n"
0768:            		+ "afterStart (Object b,Object n) {\n\n\n"
0769:            		+ "System.out.println(\"SPInstantiation test, SubProcess: \"+n.getName()+\" project: \"+(n.getBnProject()).getName());"
0770:            		+ "}";
0771:              psSub.addNodeInterHook("subNode2","subNode2",hero.interfaces.Constants.Nd.AFTERSTART,Constants.Hook.BSINTERACTIVE,script);
0772:              psSub.addUser("admin2");
0773:              psSub.setNodeRole("subNode1","admin");
0774:              
0775:              ProjectSession pss = projectSessionh.create();
0776:              pss.initModel("SPInstantiation");
0777:              pss.addNode("node1",Constants.Nd.AND_JOIN_NODE);
0778:              pss.addNode("node2",Constants.Nd.AND_JOIN_NODE);
0779:              pss.addNode("node3",Constants.Nd.AND_JOIN_NODE);
0780:              pss.addNode("node4",Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
0781:              pss.addNodeSubProcess("node5","SPInstantiation");
0782:              pss.addEdge("node1","node2");
0783:              pss.addEdge("node2","node3");
0784:              pss.addEdge("node2","node4");
0785:              pss.addEdge("node3","node5");
0786:              script =
0787:            		"import hero.interfaces.BnProjectLocal;\n"
0788:            		+ "import hero.interfaces.BnNodeLocal;\n"
0789:              		+ "afterStart (Object b,Object n) {\n\n\n"
0790:            		+ "System.out.println(\"SPInstantiation test, node: \"+n.getName()+\" project: \"+(n.getBnProject()).getName());"
0791:            		+ "}";
0792:             pss.addNodeInterHook("node2","node2",hero.interfaces.Constants.Nd.AFTERSTART,Constants.Hook.BSINTERACTIVE,script);
0793:             pss.addUser("admin2");
0794:             pss.setUserRole("admin2","InitialRole");
0795:             pss.setNodeRole("node1","admin");
0796:             ProjectSession pss1 = projectSessionh.create();
0797:             String instName=pss1.instantiateProject("SPInstantiation");
0798:             assertTrue("Instantiation Error, instance name error", pss1.getName().equals(instName));
0799:             assertTrue("Instantiation Error, role error in node1", pss1.getNodeRoleName("node1").equals("admin"));
0800:             Collection users = pss1.getUsers();
0801:             assertTrue("Instantiation Error, user admin2 does not exist", users.contains("admin2"));
0802:             assertTrue("Instantiation Error, type error in node1", pss1.getNodeType("node1")== Constants.Nd.AND_JOIN_NODE);
0803:            }
0804:            
0805:            public void testGetProjectNameOfInstance() throws Exception {
0806:                ProjectSessionHome projectSessionh=ProjectSessionUtil.getHome();
0807:                ProjectSession ps = projectSessionh.create();
0808:            	ps.initModel("ofInstance");
0809:            	ProjectSession pss1 = projectSessionh.create();
0810:            	String instanceName = pss1.instantiateProject("ofInstance");
0811:            	String projectName = pss1.getProjectNameOfInstance(instanceName);
0812:            	assertTrue("Error in getProjectNameOfInstance",projectName.equals("ofInstance"));
0813:            	try {
0814:            		projectName = pss1.getProjectNameOfInstance("ofInstance");
0815:            	 } catch (Exception io) { 
0816:            		assertTrue("getProjectNameOfInstance error when is not a valid instance",true); 
0817:            	 }		
0818:            }*/
0819:
0820:            public void testGetParent() throws Exception {
0821:                // Test when we creates a subProcess activity within a project
0822:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0823:                        .getHome();
0824:                ProjectSession ps = projectSessionh.create();
0825:
0826:                ps = projectSessionh.create();
0827:                ps.initModel("getParent");
0828:
0829:                ProjectSession ps2 = projectSessionh.create();
0830:
0831:                ps2.initModel("getParent2");
0832:
0833:                ps.addNodeSubProcess("node", "getParent2");
0834:
0835:                ps.initProject("getParent");
0836:                String p = ps.getParent();
0837:                assertTrue("Error in getParent 2 when add subProcess", p
0838:                        .equals("getParent"));
0839:
0840:                ps2.initProject("getParent2");
0841:                String p2 = ps2.getParent();
0842:                assertTrue("Error in getParent when add subProcess", p2
0843:                        .equals("getParent2"));
0844:
0845:                // Test when we creates an instance of a project
0846:                String instance = ps.instantiateProject("getParent");
0847:                String pInstance = ps.getParent();
0848:                assertTrue("Error in getParent when instantiate", pInstance
0849:                        .equals(ps.getName()));
0850:
0851:            }
0852:
0853:            public void testUnsetUserRole() throws Exception {
0854:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0855:                        .getHome();
0856:                ProjectSession ps = projectSessionh.create();
0857:                ps.initProject("unset");
0858:                ProjectSession ps2 = projectSessionh.create();
0859:                ps2.initProject("unset2");
0860:
0861:                ps.addUser("admin2");
0862:                ps.setUserRole("admin2", "InitialRole");
0863:                ps2.addUser("admin2");
0864:                ps2.setUserRole("admin2", "InitialRole");
0865:
0866:                ps.unsetUserRole("admin2", "InitialRole");
0867:                Collection names = ps.getUserRolesInProjectNames("admin2");
0868:
0869:                assertTrue("Error in unset user roles: InitialRole", !names
0870:                        .contains("InitialRole"));
0871:                assertTrue("Error in unset user roles: admin", names
0872:                        .contains("admin2"));
0873:            }
0874:
0875:            public void testMapper() throws Exception {
0876:
0877:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0878:                        .getHome();
0879:                ProjectSession pss = projectSessionh.create();
0880:                String projectName = "TestMapperProperties5";
0881:                pss.initModel(projectName);
0882:
0883:                String role1 = "Admintata";
0884:                pss.addRole(role1, "role pour activity 1");
0885:                pss.addNode("node1", Constants.Nd.AND_JOIN_NODE);
0886:                pss.setNodeRole("node1", role1);
0887:
0888:                //  add mapper
0889:                pss
0890:                        .addRoleMapper(role1, "mapper1",
0891:                                Constants.Mapper.PROPERTIES);
0892:
0893:                java.util.Collection co = null;
0894:                co = pss.getRoleMappers();
0895:                java.util.Iterator it = co.iterator();
0896:                String mapperName = "";
0897:                int mapperType = 100;
0898:                while (it.hasNext()) {
0899:                    BnRoleMapperValue mv = (BnRoleMapperValue) it.next();
0900:                    mapperName = mv.getName();
0901:                    mapperType = mv.getType();
0902:                }
0903:                System.out.println("mapperName = " + mapperName);
0904:                assertTrue("Error retreiving the created mapper name",
0905:                        "mapper1".equals(mapperName));
0906:                assertTrue("Error retreiving the created mapper id",
0907:                        Constants.Mapper.PROPERTIES == mapperType);
0908:
0909:                // Execution of the mapper at instantiation
0910:                pss.instantiateProject(projectName);
0911:
0912:                String creator = pss.getCreator();
0913:                co = pss.getUserRolesInProjectNames(creator);
0914:                assertTrue("Role Admintata has not been set to the creator", co
0915:                        .contains(creator));
0916:            }
0917:
0918:            public void testLazyInstantiation() throws Exception {
0919:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0920:                        .getHome();
0921:                ProjectSession ps = projectSessionh.create();
0922:                ps.initModel("LazyProject");
0923:
0924:                // add Nodes
0925:                ps.addNode("node0", Constants.Nd.AND_JOIN_NODE);
0926:                ps.addNode("node1", Constants.Nd.AND_JOIN_NODE);
0927:                ps.addNode("node3", Constants.Nd.AND_JOIN_NODE);
0928:                ps.addNode("node4", Constants.Nd.OR_JOIN_NODE);
0929:                ps.setNodeTraditional("node4");
0930:                ps.addNode("node5", Constants.Nd.AND_JOIN_NODE);
0931:
0932:                //	add Edges
0933:                ps.addEdge("node0", "node1");
0934:                ps.addEdge("node1", "node3");
0935:                ps.addEdge("node1", "node4");
0936:                ps.addEdge("node1", "node5");
0937:
0938:                ps.addRoleMapper("InitialRole", "roleMapperTest",
0939:                        Constants.Mapper.PROPERTIES);
0940:
0941:                String instName = ps.instantiateProject("LazyProject");
0942:                assertTrue(
0943:                        "Error in number of nodes after instantiation, number of nodes:"
0944:                                + ps.getNodesNames().size(), ps.getNodesNames()
0945:                                .size() == 1);
0946:
0947:                UserSessionHome userSessionh = UserSessionUtil.getHome();
0948:                UserSession us = userSessionh.create();
0949:                assertTrue("Error in roleMapper", us.getToDoList(instName)
0950:                        .contains("node0"));
0951:            }
0952:
0953:            public void testLazyInstantiationexecution() throws Exception {
0954:                ProjectSessionHome projectSessionh = ProjectSessionUtil
0955:                        .getHome();
0956:                ProjectSession ps = projectSessionh.create();
0957:                ps.initModel("LazyProjectExec");
0958:
0959:                // add Nodes
0960:                ps.addNode("node0", Constants.Nd.AND_JOIN_NODE);
0961:                ps.addNode("node1", Constants.Nd.AND_JOIN_NODE);
0962:                ps.addNode("node2", Constants.Nd.AND_JOIN_NODE);
0963:                ps.addNode("node3", Constants.Nd.AND_JOIN_NODE);
0964:                ps.addNode("node4", Constants.Nd.OR_JOIN_NODE);
0965:                ps.setNodeTraditional("node4");
0966:                ps.addNode("node5", Constants.Nd.AND_JOIN_NODE);
0967:                ps.addNode("node6", Constants.Nd.AND_JOIN_NODE);
0968:                ps.addNode("node7", Constants.Nd.AND_JOIN_NODE);
0969:                ps.addNode("node8", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
0970:                ps.setNodeTraditional("node8");
0971:                ps.addNode("node9", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
0972:                ps.setNodeTraditional("node9");
0973:
0974:                //	add Edges
0975:                ps.addEdge("node0", "node1");
0976:                ps.addEdge("node1", "node3");
0977:                ps.addEdge("node1", "node4");
0978:                ps.addEdge("node1", "node5");
0979:                ps.addEdge("node3", "node6");
0980:                ps.addEdge("node4", "node6");
0981:                ps.addEdge("node4", "node2");
0982:                ps.addEdge("node5", "node6");
0983:                ps.addEdge("node6", "node7");
0984:                ps.addEdge("node3", "node8");
0985:                ps.addEdge("node8", "node9");
0986:                ps.addEdge("node5", "node4");
0987:
0988:                String instName = ps.instantiateProject("LazyProjectExec");
0989:                UserSessionHome userSessionh = UserSessionUtil.getHome();
0990:                UserSession us = userSessionh.create();
0991:                us.startActivity(instName, "node0");
0992:                assertTrue(
0993:                        "Error in state of node0 after start node0",
0994:                        ps.getNodeValue("node0").getState() == Constants.Nd.EXECUTING);
0995:                assertTrue(
0996:                        "Error in state of node1 after start node0",
0997:                        ps.getNodeValue("node1").getState() == Constants.Nd.ANTICIPABLE);
0998:                assertTrue(
0999:                        "Error in state of node3 after start node0",
1000:                        ps.getNodeValue("node3").getState() == Constants.Nd.INITIAL);
1001:                assertTrue(
1002:                        "Error in state of node4 after start node0",
1003:                        ps.getNodeValue("node4").getState() == Constants.Nd.INITIAL);
1004:                assertTrue(
1005:                        "Error in state of node5 after start node0",
1006:                        ps.getNodeValue("node5").getState() == Constants.Nd.INITIAL);
1007:                assertTrue(
1008:                        "Error in number of nodes after start node0, number of nodes:"
1009:                                + ps.getNodesNames().size(), ps.getNodesNames()
1010:                                .size() == 5);
1011:                us.terminateActivity(instName, "node0");
1012:                assertTrue(
1013:                        "Error in state of node0 after terminate node0",
1014:                        ps.getNodeValue("node0").getState() == Constants.Nd.TERMINATED);
1015:                assertTrue("Error in state of node1 after terminate node0", ps
1016:                        .getNodeValue("node1").getState() == Constants.Nd.READY);
1017:                assertTrue(
1018:                        "Error in state of node3 after terminate node0",
1019:                        ps.getNodeValue("node3").getState() == Constants.Nd.INITIAL);
1020:                assertTrue(
1021:                        "Error in state of node4 after terminate node0",
1022:                        ps.getNodeValue("node4").getState() == Constants.Nd.INITIAL);
1023:                assertTrue(
1024:                        "Error in state of node5 after terminate node0",
1025:                        ps.getNodeValue("node5").getState() == Constants.Nd.INITIAL);
1026:                assertTrue(
1027:                        "Error in number of nodes after terminate node0, number of nodes:"
1028:                                + ps.getNodesNames().size(), ps.getNodesNames()
1029:                                .size() == 5);
1030:                us.startActivity(instName, "node1");
1031:                assertTrue(
1032:                        "Error in state of node1 after start node1",
1033:                        ps.getNodeValue("node1").getState() == Constants.Nd.EXECUTING);
1034:                assertTrue(
1035:                        "Error in state of node3 after start node1",
1036:                        ps.getNodeValue("node3").getState() == Constants.Nd.ANTICIPABLE);
1037:                assertTrue(
1038:                        "Error in state of node4 after start node1",
1039:                        ps.getNodeValue("node4").getState() == Constants.Nd.INITIAL);
1040:                assertTrue(
1041:                        "Error in state of node5 after start node1",
1042:                        ps.getNodeValue("node5").getState() == Constants.Nd.ANTICIPABLE);
1043:                assertTrue(
1044:                        "Error in state of node6 after start node1",
1045:                        ps.getNodeValue("node6").getState() == Constants.Nd.INITIAL);
1046:                assertTrue(
1047:                        "Error in state of node8 after start node1",
1048:                        ps.getNodeValue("node8").getState() == Constants.Nd.INITIAL);
1049:                assertTrue(
1050:                        "Error in number of nodes after start node1, number of nodes:"
1051:                                + ps.getNodesNames().size(), ps.getNodesNames()
1052:                                .size() == 7);
1053:                us.startActivity(instName, "node3");
1054:                us.startActivity(instName, "node5");
1055:                assertTrue(
1056:                        "Error in state of node1 after start node3 and node5",
1057:                        ps.getNodeValue("node1").getState() == Constants.Nd.EXECUTING);
1058:                assertTrue(
1059:                        "Error in state of node3 after start node3 and node5",
1060:                        ps.getNodeValue("node3").getState() == Constants.Nd.ANTICIPATING);
1061:                assertTrue(
1062:                        "Error in state of node4 after start node3 and node5",
1063:                        ps.getNodeValue("node4").getState() == Constants.Nd.INITIAL);
1064:                assertTrue(
1065:                        "Error in state of node5 after start node3 and node5",
1066:                        ps.getNodeValue("node5").getState() == Constants.Nd.ANTICIPATING);
1067:                assertTrue(
1068:                        "Error in state of node6 after start node3 and node5",
1069:                        ps.getNodeValue("node6").getState() == Constants.Nd.INITIAL);
1070:                assertTrue(
1071:                        "Error in state of node8 after start node3 and node5",
1072:                        ps.getNodeValue("node8").getState() == Constants.Nd.INITIAL);
1073:                assertTrue(
1074:                        "Error in number of nodes after start node3 and node5, number of nodes:"
1075:                                + ps.getNodesNames().size(), ps.getNodesNames()
1076:                                .size() == 7);
1077:                us.terminateActivity(instName, "node1");
1078:                us.terminateActivity(instName, "node3");
1079:                us.terminateActivity(instName, "node5");
1080:                assertTrue(
1081:                        "Error in state of node1 after terminate node1,node3 and node5",
1082:                        ps.getNodeValue("node1").getState() == Constants.Nd.TERMINATED);
1083:                assertTrue(
1084:                        "Error in state of node2 after terminate node1,node3 and node5",
1085:                        ps.getNodeValue("node2").getState() == Constants.Nd.INITIAL);
1086:                assertTrue(
1087:                        "Error in state of node3 after terminate node1,node3 and node5",
1088:                        ps.getNodeValue("node3").getState() == Constants.Nd.TERMINATED);
1089:                assertTrue(
1090:                        "Error in state of node4 after terminate node1,node3 and node5",
1091:                        ps.getNodeValue("node4").getState() == Constants.Nd.READY);
1092:                assertTrue(
1093:                        "Error in state of node5 after terminate node1,node3 and node5",
1094:                        ps.getNodeValue("node5").getState() == Constants.Nd.TERMINATED);
1095:                assertTrue(
1096:                        "Error in state of node6 after terminate node1,node3 and node5",
1097:                        ps.getNodeValue("node6").getState() == Constants.Nd.INITIAL);
1098:                assertTrue(
1099:                        "Error in state of node8 after terminate node1,node3 and node5",
1100:                        ps.getNodeValue("node8").getState() == Constants.Nd.TERMINATED);
1101:                assertTrue(
1102:                        "Error in state of node9 after terminate node1,node3 and node5",
1103:                        ps.getNodeValue("node9").getState() == Constants.Nd.TERMINATED);
1104:                assertTrue(
1105:                        "Error in number of nodes after start node3 and node5, number of nodes:"
1106:                                + ps.getNodesNames().size(), ps.getNodesNames()
1107:                                .size() == 9);
1108:                us.startActivity(instName, "node4");
1109:                us.terminateActivity(instName, "node4");
1110:
1111:                us.startActivity(instName, "node6");
1112:                us.terminateActivity(instName, "node6");
1113:
1114:                us.startActivity(instName, "node7");
1115:                us.terminateActivity(instName, "node7");
1116:
1117:                try {
1118:                    us.terminate(instName);
1119:                    assertTrue(
1120:                            "Error in terminate project, terminate project should be failed",
1121:                            false);
1122:                } catch (Exception e) {
1123:                }
1124:
1125:                us.startActivity(instName, "node2");
1126:                us.terminateActivity(instName, "node2");
1127:            }
1128:
1129:            public void testUnsetUser() throws Exception {
1130:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1131:                        .getHome();
1132:                ProjectSession ps = projectSessionh.create();
1133:                ps.initProject("unsetUser");
1134:                ProjectSession ps2 = projectSessionh.create();
1135:                ps2.initProject("unsetUser2");
1136:
1137:                ps.addUser("admin2");
1138:                assertTrue("Error in add user: ", ps.getUsers().contains(
1139:                        "admin2"));
1140:
1141:                ps2.addUser("admin2");
1142:                assertTrue("Error in add user (2): ", ps2.getUsers().contains(
1143:                        "admin2"));
1144:
1145:                ps.unsetUser("admin2");
1146:                assertTrue("Error in unset user: ", !ps.getUsers().contains(
1147:                        "admin2"));
1148:                assertTrue("Error in add user (3): ", ps2.getUsers().contains(
1149:                        "admin2"));
1150:
1151:                ps2.unsetUser("admin2");
1152:                assertTrue("Error in unset user (2): ", !ps2.getUsers()
1153:                        .contains("admin2"));
1154:            }
1155:
1156:            public void testGetUsersRole() throws Exception {
1157:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1158:                        .getHome();
1159:                ProjectSession ps = projectSessionh.create();
1160:                ps.initProject("getUsersRole");
1161:                ps.addUser("admin2");
1162:
1163:                ps.addRole("roleTest", "");
1164:                ps.setUserRole("admin2", "roleTest");
1165:
1166:                assertTrue("Error in getUsersRole (1): ", ps.getUsersRole(
1167:                        "roleTest").contains("admin2"));
1168:                assertTrue("Error in getUsersRole (1): ", !ps.getUsersRole(
1169:                        "roleTest").contains("admin"));
1170:            }
1171:
1172:            public void testPropertyPossibleValues() throws Exception {
1173:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1174:                        .getHome();
1175:                ProjectSession ps = projectSessionh.create();
1176:                ps.initProject("ProjectPossibleValues");
1177:                ArrayList values = new ArrayList();
1178:                values.add("value1");
1179:                values.add("value2");
1180:
1181:                ps.setPropertyPossibleValues("key1", values);
1182:                try {
1183:                    ps.setProperty("key1", "value3");
1184:                    assertTrue("Error setProperty should be failed", false);
1185:                } catch (Exception e) {
1186:                }
1187:                ps.setProperty("key1", "value2");
1188:            }
1189:
1190:            public void testNodePropertyPossibleValues() throws Exception {
1191:                UserSessionHome usersh = UserSessionUtil.getHome();
1192:                UserSession user = usersh.create();
1193:
1194:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1195:                        .getHome();
1196:                ProjectSession ps = projectSessionh.create();
1197:                ps.initModel("ProjectNodesPossibleValues");
1198:                ps.addNode("node1", 1);
1199:                ps.addNode("node2", 1);
1200:                ps.addNode("node3", 1);
1201:                ps.addEdge("node1", "node2");
1202:                ps.addEdge("node2", "node3");
1203:                ps.setNodeRole("node1", Constants.ADMIN);
1204:                ps.setNodeRole("node2", Constants.ADMIN);
1205:                ps.setNodeRole("node3", Constants.ADMIN);
1206:                ArrayList values = new ArrayList();
1207:                values.add("value1");
1208:                values.add("value2");
1209:
1210:                ps.setNodePropertyPossibleValues("node1", "key1", values);
1211:                try {
1212:                    ps.setNodeProperty("node1", "key1", "value3");
1213:                    assertTrue("Error setNodeProperty should be failed", false);
1214:                } catch (Exception e) {
1215:                }
1216:                ps.setNodeProperty("node1", "key1", "value2", true);
1217:                String instName = ps
1218:                        .instantiateProject("ProjectNodesPossibleValues");
1219:
1220:                user.startActivity(instName, "node1");
1221:                user.terminateActivity(instName, "node1");
1222:
1223:                BnNodePropertyValue pv = ps.getNodeProperty("node2", "key1");
1224:
1225:                assertTrue("Error testNodeProperty after instantiation", pv
1226:                        .getPossibleValues().size() == 2);
1227:
1228:                user.startActivity(instName, "node2");
1229:                user.terminateActivity(instName, "node2");
1230:
1231:                pv = ps.getNodeProperty("node3", "key1");
1232:
1233:                assertTrue("Error testNodeProperty after instantiation 2", pv
1234:                        .getPossibleValues().size() == 2);
1235:            }
1236:
1237:            public void testUpdateNodePropertyPossibleValues() throws Exception {
1238:                UserSessionHome usersh = UserSessionUtil.getHome();
1239:                UserSession user = usersh.create();
1240:
1241:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1242:                        .getHome();
1243:                ProjectSession ps = projectSessionh.create();
1244:                ps.initModel("UpdateProjectNodesPossibleValues");
1245:                ps.addNode("node1", 1);
1246:                ps.addNode("node2", 1);
1247:                ps.addNode("node3", 1);
1248:                ps.addEdge("node1", "node2");
1249:                ps.addEdge("node2", "node3");
1250:                ps.setNodeRole("node1", Constants.ADMIN);
1251:                ps.setNodeRole("node2", Constants.ADMIN);
1252:                ps.setNodeRole("node3", Constants.ADMIN);
1253:                ArrayList values = new ArrayList();
1254:                values.add("value1");
1255:                values.add("value2");
1256:
1257:                ps.setNodePropertyPossibleValues("node1", "key1", values);
1258:                try {
1259:                    ps.setNodeProperty("node1", "key1", "value3");
1260:                    assertTrue("Error setNodeProperty should be failed", false);
1261:                } catch (Exception e) {
1262:                }
1263:                ps.setNodeProperty("node1", "key1", "value2", true);
1264:                String instName = ps
1265:                        .instantiateProject("UpdateProjectNodesPossibleValues");
1266:
1267:                user.startActivity(instName, "node1");
1268:                user.terminateActivity(instName, "node1");
1269:
1270:                BnNodePropertyValue pv = ps.getNodeProperty("node2", "key1");
1271:
1272:                assertTrue("Error testNodeProperty after instantiation", pv
1273:                        .getPossibleValues().size() == 2);
1274:
1275:                values = new ArrayList();
1276:                values.add("value3");
1277:                values.add("value4");
1278:                values.add("value5");
1279:                ArrayList ardf = new ArrayList();
1280:                ardf.add("value3");
1281:                ps.updateNodePropertyPossibleValues("node2", "key1", values,
1282:                        ardf);
1283:
1284:                pv = ps.getNodeProperty("node2", "key1");
1285:
1286:                assertTrue("Error testNodeProperty after instantiation", pv
1287:                        .getPossibleValues().size() == 3);
1288:
1289:                user.startActivity(instName, "node2");
1290:                user.terminateActivity(instName, "node2");
1291:
1292:                pv = ps.getNodeProperty("node3", "key1");
1293:
1294:                assertTrue("Error testNodeProperty after instantiation 2", pv
1295:                        .getPossibleValues().size() == 3);
1296:            }
1297:
1298:            public void testUpdatePropertyPossibleValues() throws Exception {
1299:                UserSessionHome usersh = UserSessionUtil.getHome();
1300:                UserSession user = usersh.create();
1301:
1302:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1303:                        .getHome();
1304:                ProjectSession ps = projectSessionh.create();
1305:                ps.initModel("UpdateProjectPossibleValues");
1306:                ps.addNode("node1", 1);
1307:                ps.addNode("node2", 1);
1308:                ps.addNode("node3", 1);
1309:                ps.addEdge("node1", "node2");
1310:                ps.addEdge("node2", "node3");
1311:                ps.setNodeRole("node1", Constants.ADMIN);
1312:                ps.setNodeRole("node2", Constants.ADMIN);
1313:                ps.setNodeRole("node3", Constants.ADMIN);
1314:                ArrayList values = new ArrayList();
1315:                values.add("value1");
1316:                values.add("value2");
1317:
1318:                ps.setPropertyPossibleValues("key1", values);
1319:                try {
1320:                    ps.setProperty("key1", "value3");
1321:                    assertTrue("Error setNodeProperty should be failed", false);
1322:                } catch (Exception e) {
1323:                }
1324:                ps.setProperty("key1", "value2");
1325:                String instName = ps
1326:                        .instantiateProject("UpdateProjectPossibleValues");
1327:
1328:                user.startActivity(instName, "node1");
1329:                user.terminateActivity(instName, "node1");
1330:
1331:                BnProjectPropertyValue pv = ps.getProperty("key1");
1332:
1333:                assertTrue("Error testProperty after instantiation", pv
1334:                        .getPossibleValues().size() == 2);
1335:
1336:                values = new ArrayList();
1337:                values.add("value3");
1338:                values.add("value4");
1339:                values.add("value5");
1340:                ArrayList ardf = new ArrayList();
1341:                ardf.add("value3");
1342:                ps.updatePropertyPossibleValues("key1", values, ardf);
1343:
1344:                pv = ps.getProperty("key1");
1345:
1346:                assertTrue("Error testProperty after instantiation", pv
1347:                        .getPossibleValues().size() == 3);
1348:
1349:                user.startActivity(instName, "node2");
1350:                user.terminateActivity(instName, "node2");
1351:
1352:                pv = ps.getProperty("key1");
1353:
1354:                assertTrue("Error testProperty after instantiation 2", pv
1355:                        .getPossibleValues().size() == 3);
1356:            }
1357:
1358:            public void testAddDeleteInitiatorMapper() throws Exception {
1359:                ProjectSessionHome pHome = ProjectSessionUtil.getHome();
1360:                ProjectSession lProject = pHome.create();
1361:                lProject.initModel("InitiatorModel");
1362:                lProject.addInitiatorMapper(
1363:                        "hero.initiatorMapper.CustomGroupMembers",
1364:                        Constants.InitiatorMapper.CUSTOM);
1365:                String instName = lProject.instantiateProject("InitiatorModel");
1366:                UserSessionHome uHome = UserSessionUtil.getHome();
1367:                UserSession user = uHome.create();
1368:                user.removeProject(instName);
1369:                user.removeProject("InitiatorModel");
1370:                assertTrue("Error testAddDeleteInitiator", lProject
1371:                        .existingProject("InitiatorProject") == false);
1372:            }
1373:
1374:            public void testSimpleVersioningTest() throws Exception {
1375:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1376:                        .getHome();
1377:                ProjectSession pss = projectSessionh.create();
1378:
1379:                pss.initModelWithVersion("Approval_workflow_versioned", "1.0");
1380:                pss.addNode("Approval", Constants.Nd.AND_JOIN_NODE);
1381:                pss.addNode("Approval2", Constants.Nd.AND_JOIN_NODE);
1382:                pss.addEdge("Approval", "Approval2");
1383:
1384:                pss.initModelWithVersion("Approval_workflow_versioned", "1.1");
1385:                pss.addNode("Approval", Constants.Nd.AND_JOIN_NODE);
1386:                pss.addNode("Approval2", Constants.Nd.AND_JOIN_NODE);
1387:                pss.addEdge("Approval", "Approval2");
1388:
1389:                String instName = pss.instantiateProject(
1390:                        "Approval_workflow_versioned", "1.1");
1391:
1392:                assertTrue("Error instance version", pss.getDetails()
1393:                        .getVersion().equals("1.1"));
1394:
1395:                UserSessionHome userSessionh = UserSessionUtil.getHome();
1396:                UserSession uss = userSessionh.create();
1397:                uss.startActivity(instName, "Approval");
1398:                assertTrue("Error Approval activity state", pss
1399:                        .getNodeState("Approval") == Constants.Nd.EXECUTING);
1400:
1401:                uss.terminateActivity(instName, "Approval");
1402:                assertTrue("Error Approval activity state", pss
1403:                        .getNodeState("Approval") == Constants.Nd.TERMINATED);
1404:
1405:                uss.startActivity(instName, "Approval2");
1406:                assertTrue("Error Approval2 activity state", pss
1407:                        .getNodeState("Approval2") == Constants.Nd.EXECUTING);
1408:                assertTrue("Error Approval2 model version", pss.getNodeValue(
1409:                        "Approval2").getBnProject().getVersion().equals("1.1"));
1410:
1411:                uss.terminateActivity(instName, "Approval2");
1412:
1413:                String instName2 = pss.instantiateProject(
1414:                        "Approval_workflow_versioned", "1.0");
1415:
1416:                assertTrue("Error instance version 2", pss.getDetails()
1417:                        .getVersion().equals("1.0"));
1418:
1419:                uss.startActivity(instName2, "Approval");
1420:                assertTrue("Error Approval activity state 2", pss
1421:                        .getNodeState("Approval") == Constants.Nd.EXECUTING);
1422:
1423:                uss.terminateActivity(instName2, "Approval");
1424:                assertTrue("Error Approval activity state 2", pss
1425:                        .getNodeState("Approval") == Constants.Nd.TERMINATED);
1426:
1427:                uss.startActivity(instName2, "Approval2");
1428:                assertTrue("Error Approval2 activity state 2", pss
1429:                        .getNodeState("Approval2") == Constants.Nd.EXECUTING);
1430:                assertTrue("Error Approval2 model version 2", pss.getNodeValue(
1431:                        "Approval2").getBnProject().getVersion().equals("1.0"));
1432:
1433:                uss.terminateActivity(instName2, "Approval2");
1434:
1435:                instName = pss.instantiateProject(
1436:                        "Approval_workflow_versioned", "1.1");
1437:                uss.removeInstance(instName);
1438:
1439:                instName = pss.instantiateProject(
1440:                        "Approval_workflow_versioned", "1.0");
1441:                uss.removeInstance(instName);
1442:
1443:                try {
1444:                    uss.removeInstance(instName);
1445:                    assertTrue("Should have throw EJBException", false);
1446:                } catch (Exception e) {
1447:                    //expected behavior
1448:                }
1449:
1450:                uss.removeProject("Approval_workflow_versioned", "1.0");
1451:                uss.removeProject("Approval_workflow_versioned", "1.1");
1452:            }
1453:
1454:            public void testDynamicEnumerationPropagation() throws Exception {
1455:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1456:                        .getHome();
1457:                ProjectSession pss = projectSessionh.create();
1458:
1459:                pss.initModelWithVersion("DynamicEnumPropagation", "1.0");
1460:                pss.addNode("start", Constants.Nd.AND_JOIN_NODE);
1461:                pss.addNode("appro3", Constants.Nd.AND_JOIN_NODE);
1462:                pss.addNode("appro3OK", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
1463:                pss.addNode("approv3bis", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
1464:                pss.addNode("End", Constants.Nd.AND_JOIN_NODE);
1465:
1466:                pss.addNodeHook("appro3OK", "hero.hook.UpdateEnumDyn",
1467:                        Constants.Nd.BEFORETERMINATE, Constants.Hook.JAVA);
1468:
1469:                pss.addEdge("start", "appro3");
1470:                pss.addEdge("appro3", "appro3OK");
1471:                pss.addEdge("appro3OK", "approv3bis");
1472:                pss.addEdge("appro3OK", "End");
1473:
1474:                // Set node properties
1475:                Collection cas = new ArrayList();
1476:                cas.add("cas1");
1477:                cas.add("cas2");
1478:                cas.add("cas3");
1479:                pss.setNodePropertyPossibleValues("start", "cas", cas);
1480:                pss.setNodeProperty("start", "cas", "cas3", true);
1481:
1482:                Collection approv = new ArrayList();
1483:                approv.add("yes");
1484:                approv.add("no");
1485:                pss.setNodePropertyPossibleValues("start", "approv", approv);
1486:                pss.setNodeProperty("start", "approv", "yes", true);
1487:
1488:                Collection enumdyn = new ArrayList();
1489:                enumdyn.add("default");
1490:                pss.setNodePropertyPossibleValues("start", "enumdyn", enumdyn);
1491:                pss.setNodeProperty("start", "enumdyn", "default", true);
1492:
1493:                pss.setNodeProperty("appro3", "mykey", "myvalue");
1494:
1495:                String instName = pss.instantiateProject(
1496:                        "DynamicEnumPropagation", "1.0");
1497:
1498:                assertTrue("Error instance version", pss.getDetails()
1499:                        .getVersion().equals("1.0"));
1500:
1501:                UserSessionHome userSessionh = UserSessionUtil.getHome();
1502:                UserSession uss = userSessionh.create();
1503:
1504:                uss.startActivity(instName, "start");
1505:                assertTrue("Error start activity state", pss
1506:                        .getNodeState("start") == Constants.Nd.EXECUTING);
1507:
1508:                uss.terminateActivity(instName, "start");
1509:                assertTrue("Error start activity state", pss
1510:                        .getNodeState("start") == Constants.Nd.TERMINATED);
1511:
1512:                uss.startActivity(instName, "appro3");
1513:                assertTrue("Error appro3 activity state", pss
1514:                        .getNodeState("appro3") == Constants.Nd.EXECUTING);
1515:                assertTrue("Error appro3 model version", pss.getNodeValue(
1516:                        "appro3").getBnProject().getVersion().equals("1.0"));
1517:
1518:                uss.terminateActivity(instName, "appro3");
1519:                assertTrue("Error End activity state",
1520:                        pss.getNodeState("End") == Constants.Nd.READY);
1521:
1522:            }
1523:
1524:            public void testPropertiesPropagation() throws Exception {
1525:                ProjectSessionHome projectSessionh = ProjectSessionUtil
1526:                        .getHome();
1527:                ProjectSession pss = projectSessionh.create();
1528:
1529:                pss.initModelWithVersion("PropertiesPropagation", "1.0");
1530:                pss.addNode("appro3OK", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
1531:                pss.addNode("approv3bis", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
1532:                pss.addNode("MyManual", Constants.Nd.AND_JOIN_NODE);
1533:                pss.addNode("End", Constants.Nd.AND_JOIN_NODE);
1534:
1535:                pss.addNodeHook("appro3OK", "hero.hook.UpdateEnumDyn",
1536:                        Constants.Nd.BEFORETERMINATE, Constants.Hook.JAVA);
1537:                pss.addNodeHook("MyManual", "hero.hook.UpdateEnumDyn2",
1538:                        Constants.Nd.BEFORETERMINATE, Constants.Hook.JAVA);
1539:                pss.addNodeHook("End", "hero.hook.UpdateEnumDyn3",
1540:                        Constants.Nd.ONREADY, Constants.Hook.JAVA);
1541:
1542:                pss.addEdge("appro3OK", "approv3bis");
1543:                pss.addEdge("appro3OK", "MyManual");
1544:                pss.addEdge("MyManual", "End");
1545:
1546:                // Set node properties
1547:                Collection cas = new ArrayList();
1548:                cas.add("cas1");
1549:                cas.add("cas2");
1550:                cas.add("cas3");
1551:                pss.setNodePropertyPossibleValues("appro3OK", "cas", cas);
1552:                pss.setNodeProperty("appro3OK", "cas", "cas3", true);
1553:
1554:                pss.setNodeProperty("appro3OK", "testProp", "yes", true);
1555:
1556:                Collection enumdyn = new ArrayList();
1557:                enumdyn.add("default");
1558:                pss.setNodePropertyPossibleValues("appro3OK", "enumdyn",
1559:                        enumdyn);
1560:                pss.setNodeProperty("appro3OK", "enumdyn", "default", true);
1561:
1562:                String instName = pss.instantiateProject(
1563:                        "PropertiesPropagation", "1.0");
1564:
1565:                assertTrue("Error instance version", pss.getDetails()
1566:                        .getVersion().equals("1.0"));
1567:                assertTrue("Error start activity state 1 ", pss
1568:                        .getNodeState("appro3OK") == Constants.Nd.TERMINATED);
1569:                assertTrue("Error start activity state 2 ", pss
1570:                        .getNodeState("approv3bis") == Constants.Nd.TERMINATED);
1571:
1572:                assertTrue("Error value property enumdyn ", pss
1573:                        .getNodeProperty("approv3bis", "enumdyn").getTheValue()
1574:                        .equals("miguel"));
1575:
1576:                UserSessionHome userSessionh = UserSessionUtil.getHome();
1577:                UserSession uss = userSessionh.create();
1578:
1579:                uss.startActivity(instName, "MyManual");
1580:                assertTrue("Error start activity state", pss
1581:                        .getNodeState("MyManual") == Constants.Nd.EXECUTING);
1582:                assertTrue("Error value property testprop ", pss
1583:                        .getNodeProperty("MyManual", "testProp").getTheValue()
1584:                        .equals("yes"));
1585:
1586:                uss.terminateActivity(instName, "MyManual");
1587:                assertTrue("Error start activity state", pss
1588:                        .getNodeState("MyManual") == Constants.Nd.TERMINATED);
1589:
1590:                assertTrue("Error End activity state",
1591:                        pss.getNodeState("End") == Constants.Nd.READY);
1592:                assertTrue("Error value property enumdyn ", pss
1593:                        .getNodeProperty("MyManual", "enumdyn").getTheValue()
1594:                        .equals("new1"));
1595:                assertTrue("Error value property enumdyn ", pss
1596:                        .getNodeProperty("End", "enumdyn").getTheValue()
1597:                        .equals("newValue"));
1598:                assertTrue("Error value property testprop ", pss
1599:                        .getNodeProperty("End", "testProp").getTheValue()
1600:                        .equals("yes"));
1601:            }
1602:
1603:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.