001: /*
002: * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
003: * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
004: * Copyright (C) 2007 Sebastien BALARD <sbalard@wilos-project.org>
005: *
006: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
007: * General Public License as published by the Free Software Foundation; either version 2 of the License,
008: * or (at your option) any later version.
009: *
010: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
011: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License along with this program; if not,
015: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
016: */
017: package wilos.test.business.services.spem2.process;
018:
019: import static org.junit.Assert.assertEquals;
020: import static org.junit.Assert.assertNotNull;
021:
022: import java.io.File;
023: import java.util.List;
024:
025: import org.junit.After;
026: import org.junit.Before;
027: import org.junit.Test;
028:
029: import wilos.business.services.misc.wilosuser.ProcessManagerService;
030: import wilos.business.services.spem2.process.ProcessService;
031: import wilos.model.misc.wilosuser.ProcessManager;
032: import wilos.model.spem2.process.Process;
033: import wilos.test.TestConfiguration;
034:
035: public class ProcessServiceTest {
036: // public static File pathOPenUP_0_9 =new File("processes"+ File.separator +
037: // "openUP.xml");
038: public static File pathOPenUP_1_0 = new File("processes"
039: + File.separator + "openUP1.0.xml");
040:
041: private ProcessService processService = (ProcessService) TestConfiguration
042: .getInstance().getApplicationContext().getBean(
043: "ProcessService");
044:
045: private ProcessManagerService processManagerService = (ProcessManagerService) TestConfiguration
046: .getInstance().getApplicationContext().getBean(
047: "ProcessManagerService");
048:
049: private Process process;
050:
051: private ProcessManager processManager;
052:
053: private String processId;
054:
055: @Before
056: public void setUp() {
057:
058: this .processManager = new ProcessManager();
059: this .processManager.setLogin("My login");
060: this .processManager.setName("My name");
061: this .processManager.setPassword("My password");
062: this .processManagerService
063: .saveProcessManager(this .processManager);
064:
065: this .process = new Process();
066: this .process.setGuid("My guid");
067: this .process.addProcessManager(this .processManager);
068: }
069:
070: @After
071: public void tearDown() {
072: this .processManagerService
073: .deleteProcessManager(this .processManager);
074: this .processManager = null;
075: this .process = null;
076: }
077:
078: @Test
079: public void testStorageOfAnProcessInATransaction() {
080:
081: this .processId = this .processService.saveProcess(this .process);
082: this .processManagerService
083: .saveProcessManager(this .processManager);
084:
085: Process retrievedProcess = this .processService.getProcessDao()
086: .getProcess(this .processId);
087: assertNotNull("not null", retrievedProcess);
088:
089: this .process.removeProcessManager(this .processManager);
090: // this.processManager.getProcessesManaged().clear();
091: this .processManagerService
092: .saveProcessManager(this .processManager);
093:
094: this .processService.deleteProcess(this .process);
095: }
096:
097: @Test
098: public void testThatAllProcessesAreRetrieved() {
099:
100: int nb = this .processService.getAllProcesses().size();
101:
102: this .processId = this .processService.saveProcess(this .process);
103:
104: Process p1 = new Process();
105: p1.setName("Your name");
106: p1.setDescription("Your description");
107:
108: this .processService.saveProcess(p1);
109:
110: Process p2 = new Process();
111: p2.setName("Its name");
112: p2.setDescription("Its description");
113:
114: this .processService.saveProcess(p2);
115:
116: List<Process> processes = this .processService.getAllProcesses();
117: assertNotNull("not null", processes);
118: assertEquals("number of processes", 3, processes.size() - nb);
119:
120: this .processService.deleteProcess(p2);
121: this .processService.deleteProcess(p1);
122: this .processService.deleteProcess(this .process);
123: p2 = null;
124: p1 = null;
125: }
126:
127: /*
128: * @Test public final void testSaveAndDeleteProcess_OpenUP_0_9() { // Rk:
129: * the setUp method is called here.
130: *
131: * Process p = processService.importProcessFromEpfComposer(pathOPenUP_0_9); //
132: * Save the process
133: * this.processService.saveProcess(p,this.processManager.getId());
134: * this.processService.deleteProcess(p); // Rk: the tearDown method is
135: * called here. }
136: */
137:
138: @Test
139: public final void testSaveAndDeletesProcess_OpenUP_1_0() {
140:
141: Process p = processService
142: .importProcessFromEpfComposer(pathOPenUP_1_0);
143: // Save the process
144: //TODO
145: //Correct this JUnit
146: //The process is already imported so it is impossible to save it another time
147: // this.processService.saveProcess(p,this.processManager.getId());
148: // this.processService.deleteProcess(p);
149: }
150: }
|