]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman-Common/src/test/splat/service/TestStepsConfigService.java
Salome HOME
Fix of checkin and removeDocument.
[tools/siman.git] / Workspace / Siman-Common / src / test / splat / service / TestStepsConfigService.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   12 Oct 2012
6  * @author         $Author$
7  * @version        $Revision$
8  *****************************************************************************/
9 package test.splat.service;
10
11 import java.io.FileNotFoundException;
12 import java.io.IOException;
13 import java.sql.SQLException;
14 import java.util.List;
15
16 import org.splat.dal.bo.som.Scenario;
17 import org.splat.dal.bo.som.Study;
18 import org.splat.log.AppLogger;
19 import org.splat.service.technical.ProjectSettingsService;
20 import org.splat.service.technical.StepsConfigService;
21 import org.splat.service.technical.ProjectSettingsService.Step;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.beans.factory.annotation.Qualifier;
24 import org.testng.Assert;
25 import org.testng.annotations.Test;
26
27 import test.splat.common.BaseTest;
28
29 /**
30  * Test class for ProjectService.
31  * 
32  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
33  * 
34  */
35 public class TestStepsConfigService extends BaseTest {
36
37         /**
38          * Logger for the class.
39          */
40         private static final AppLogger LOG = AppLogger
41                         .getLogger(TestStepsConfigService.class);
42
43         /**
44          * The ProjectSettingsService. Later injected by Spring.
45          */
46         @Autowired
47         @Qualifier("projectSettings")
48         private transient ProjectSettingsService _projectSettings;
49
50         /**
51          * The StepsConfigService. Later injected by Spring.
52          */
53         @Autowired
54         @Qualifier("stepsConfigService")
55         private transient StepsConfigService _stepsConfigService;
56
57         /**
58          * Test steps configuration. First steps do not involve scenario steps.<BR>
59          * <B>Description :</B> <BR>
60          * <i>Load configuration and check the result.</i><BR>
61          * <B>Action : </B><BR>
62          * <i>1. call the method for som.xml</i><BR>
63          * <B>Test data : </B><BR>
64          * <i>test/som.xml</i><BR>
65          * 
66          * <B>Outcome results:</B><BR>
67          * <i>
68          * <ul>
69          * <li>First step involves a study only. Other steps involve both a study and a scenario. </li>
70          * </li>
71          * </ul>
72          * </i>
73          * 
74          * @throws IOException
75          *             if configuration loading is failed
76          * @throws SQLException
77          *             if configuration loading is failed
78          */
79         @Test
80         public void testStepInvolves() throws IOException, SQLException {
81                 LOG.debug(">>>>> BEGIN testStepInvolves()()");
82                 startNestedTransaction();
83                 // ////// Load good workflow customization
84                 _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again
85                 try {
86                         _projectSettings.configure("classpath:test/som.xml");
87                 } catch (FileNotFoundException e) {
88                         Assert.fail("Can't find configuration file: ", e);
89                 }
90                 List<Step> steps = _stepsConfigService.getStepsOf(Scenario.class);
91                 Assert.assertTrue(steps.size() > 0, "No steps are created.");
92
93                 Assert.assertTrue(_stepsConfigService.stepInvolves(1, Study.class));
94                 Assert.assertFalse(_stepsConfigService.stepInvolves(1, Scenario.class));
95                 for (int i = 2; i <= steps.size(); i++) {
96                         Assert.assertTrue(_stepsConfigService.stepInvolves(i, Study.class));
97                         Assert.assertTrue(_stepsConfigService.stepInvolves(i, Scenario.class));
98                 }
99
100                 rollbackNestedTransaction();
101                 LOG.debug(">>>>> END testStepInvolves()()");
102         }
103 }