Salome HOME
Processing instruction is defined now in getScenarioInfo using document types mappings.
[tools/siman.git] / Workspace / Siman-Common / src / test / splat / service / TestScenarioService.java
index 1f0e41d1158d5185cd89cb981f9a7c8f61368449..364e55f2511865c3f11be1fbb22ebbbac9adcf0e 100644 (file)
@@ -49,7 +49,6 @@ import test.splat.common.BaseTest;
  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  * 
  */
-@Test(sequential = true, groups = { "service", "functional", "business" })
 public class TestScenarioService extends BaseTest {
 
        /**
@@ -179,7 +178,6 @@ public class TestScenarioService extends BaseTest {
                                Assert.assertTrue(step.getDocs().size() > 0,
                                                "Step documents list must not be empty.");
                                String docName = "document" + docIndex;
-                               docIndex++;
                                for (DocumentDTO doc : step.getDocs()) {
                                        if (docName.equals(doc.getTitle())) {
                                                Assert.assertTrue(doc.getId() > 0,
@@ -195,11 +193,58 @@ public class TestScenarioService extends BaseTest {
                                                                        "File path must not be null.");
                                                        Assert.assertFalse(file.getPath().isEmpty(),
                                                                        "File path must not be empty.");
-                                                       Assert.assertEquals(file.getState(), 'Y',
-                                                                       "File state must be actual ('Y').");
+                                                       /*                                                      
+                                                   <mappings>
+                                                       <document type="geometry">
+                                                           <import format="brep"/>     <!-- Result Shape                             -->
+                                                       </document>
+                                                       <document type="model">
+                                                           <import format="med"/>      <!-- Result mesh without input parameters     -->
+                                                       </document>
+                                                       <document type="loads">
+                                                           <import format="c3m"/>      <!-- Input data created interactively         -->
+                                                       </document>
+                                                       <document type="results">
+                                                           <import format="med"/>      <!-- Calculation results source file          -->
+                                                       </document>
+                                               </mappings>
+                                                        */
+                                                       // Check state and processing instruction
+                                                       String fileFormat = file.getPath().substring(
+                                                                       file.getPath().lastIndexOf('.') + 1);
+/*                                                     if (_projectSettings.doImport(dtype.getName(),
+                                                                       fileFormat)) {
+                                                               Assert.assertTrue(file.isResult(),
+                                                                               "The file must be a result file.");
+                                                       } else {
+                                                               Assert.assertFalse(file.isResult(),
+                                                                               "The file must be a source file.");
+                                                       }
+*/                                                     if ((docIndex % 2) == 0) { // New
+                                                               Assert.assertEquals(file.getState(), 'Y',
+                                                                               "File state must be actual ('Y').");
+                                                               if (_projectSettings.doImport(dtype.getName(),
+                                                                               fileFormat)) {
+                                                                       Assert.assertEquals(file.getProcessing(),
+                                                                                       "file-import",
+                                                                                       "File must be imported.");
+                                                               } else {
+                                                                       Assert.assertEquals(file.getProcessing(),
+                                                                                       "file-download",
+                                                                                       "File must be downloaded.");
+                                                               }
+                                                       } else { // Outdated
+                                                               Assert.assertEquals(file.getState(), 'O',
+                                                                               "File state must be actual ('O').");
+                                                               Assert
+                                                                               .assertEquals(file.getProcessing(),
+                                                                                               "file-download",
+                                                                                               "Outdated document should not be imported but downloaded.");
+                                                       }
                                                }
                                        }
                                }
+                               docIndex++;
                        }
                }
 
@@ -283,8 +328,11 @@ public class TestScenarioService extends BaseTest {
                                        .selectTypesOf(step);
                        for (DocumentType dtype : dtypes) {
                                dprop.setName("document" + i++).setType(dtype).setFormat(
-                                               dtype.getName());
+                                               "brep");
                                // Create a document published in the scenario
+                               // document<i>: document type[0] - first type used on the step
+                               //      <source-file>.brep
+                               //      <attached-file>.med
                                Publication pub = _stepService.createDocument(aScStep, dprop);
                                Assert.assertNotNull(pub.getOwner(),
                                                "The publication must be attached to the scenario.");
@@ -298,6 +346,29 @@ public class TestScenarioService extends BaseTest {
                                // Attach a file
                                ht.saveOrUpdate(pub.value());
                                ht.saveOrUpdate(_publicationService.attach(pub, "med"));
+                               
+                               // Create a document with outdated publication
+                               dprop.setName("document" + i++).setType(dtype).setFormat(
+                               "brep");
+                               // Create a document published in the scenario
+                               // document<i>: document type[0] - first type used on the step
+                               //      <source-file>.brep
+                               //      <attached-file>.med
+                               pub = _stepService.createDocument(aScStep, dprop);
+                               Assert.assertNotNull(pub.getOwner(),
+                                               "The publication must be attached to the scenario.");
+                               Assert.assertEquals(pub.getOwner().getIndex(), aScenario
+                                               .getIndex(),
+                                               "The publication was not attached to the scenario.");
+               
+                               pub.setIsnew('O');
+                               aScenario.add(pub);
+                               ht.saveOrUpdate(pub);
+               
+                               // Attach a file
+                               ht.saveOrUpdate(pub.value());
+                               ht.saveOrUpdate(_publicationService.attach(pub, "med"));
+                                               
                        }
                        if (dtypes.size() <= 0) {
                                LOG.debug("No document types are found for scenario step " + i);