1 /*****************************************************************************
5 * Creation date 12 Oct 2012
8 *****************************************************************************/
9 package test.splat.service;
11 import java.io.FileNotFoundException;
12 import java.io.IOException;
13 import java.sql.SQLException;
14 import java.util.List;
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;
27 import test.splat.common.BaseTest;
30 * Test class for ProjectService.
32 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
35 public class TestStepsConfigService extends BaseTest {
38 * Logger for the class.
40 private static final AppLogger LOG = AppLogger
41 .getLogger(TestStepsConfigService.class);
44 * The ProjectSettingsService. Later injected by Spring.
47 @Qualifier("projectSettings")
48 private transient ProjectSettingsService _projectSettings;
51 * The StepsConfigService. Later injected by Spring.
54 @Qualifier("stepsConfigService")
55 private transient StepsConfigService _stepsConfigService;
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>
66 * <B>Outcome results:</B><BR>
69 * <li>First step involves a study only. Other steps involve both a study and a scenario. </li>
75 * if configuration loading is failed
76 * @throws SQLException
77 * if configuration loading is failed
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
86 _projectSettings.configure("classpath:test/som.xml");
87 } catch (FileNotFoundException e) {
88 Assert.fail("Can't find configuration file: ", e);
90 List<Step> steps = _stepsConfigService.getStepsOf(Scenario.class);
91 Assert.assertTrue(steps.size() > 0, "No steps are created.");
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));
100 rollbackNestedTransaction();
101 LOG.debug(">>>>> END testStepInvolves()()");