Salome HOME
Fix for generating a description for version relation during checkin.
[tools/siman.git] / Workspace / Siman-Common / src / test / splat / service / TestScenarioService.java
index 5cf66d462b10e284686f611aa3590759aac6e6d8..baddb0191ebade1c24ed126f47637be8797899b6 100644 (file)
@@ -37,6 +37,7 @@ import org.splat.dal.bo.som.UsesRelation;
 import org.splat.dal.bo.som.ValidationCycle;
 import org.splat.dal.bo.som.ValidationCycleRelation;
 import org.splat.dal.bo.som.ValidationStep;
+import org.splat.dal.bo.som.VersionsRelation;
 import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.dao.kernel.UserDAO;
 import org.splat.dal.dao.som.Database;
@@ -457,6 +458,7 @@ public class TestScenarioService extends BaseTest {
                        createDocDTOForModule(stepToCheckin, "SMESH", "med", userId, step,
                                        stepsToCheckin);
                }
+               // /////////////////////////////////////////////////////////////////
                // Do test checkin
                _scenarioService.checkin(scenarioId, userId, stepsToCheckin);
 
@@ -511,15 +513,15 @@ public class TestScenarioService extends BaseTest {
                                                                && "geometry".equals(prevDoc.getType()
                                                                                .getName())) {
                                                        Assert.assertEquals(newPub.value().getFormat(),
-                                                                       "brep");
+                                                                       newFormat);
                                                        Assert.assertEquals(newPub.getSourceFile()
-                                                                       .getFormat(), "brep");
+                                                                       .getFormat(), newFormat);
                                                        Assert.assertEquals(newPub.getSourceFile()
                                                                        .getRelativePath().substring(
                                                                                        newPub.getSourceFile()
                                                                                                        .getRelativePath()
                                                                                                        .lastIndexOf('.') + 1),
-                                                                       "brep");
+                                                                       newFormat);
                                                }
 
                                                // Check that uses relations are copied correctly
@@ -563,6 +565,21 @@ public class TestScenarioService extends BaseTest {
                                                                                                + ") must become outdated.");
                                                        }
                                                }
+
+                                               // Check that a correct comment is generated for VersionsRelation
+                                               VersionsRelation versRel = (VersionsRelation) newPub
+                                                               .value().getFirstRelation(
+                                                                               VersionsRelation.class);
+                                               Assert.assertNotNull(versRel,
+                                                               "VersionsRelation must be created.");
+                                               Assert
+                                                               .assertNotNull(versRel.getDescription(),
+                                                                               "VersionsRelation description was not generated.");
+                                               int descrLen = versRel.getDescription().length();
+                                               Assert.assertTrue(descrLen > 0,
+                                                               "VersionsRelation description is empty.");
+                                               LOG.debug("Version description: "
+                                                               + versRel.getDescription());
                                        } else {
                                                // Otherwise the new file format must differ from the previous one
                                                // and the new file must be attached to the same document
@@ -769,8 +786,17 @@ public class TestScenarioService extends BaseTest {
                                                                || (file.getPath().endsWith("py") && (format
                                                                                .equals("brep") || format.equals("med")))) {
                                                        // Create a file in the download directory
-                                                       docToCheckin.addFile(createDownloadedFile(userId,
-                                                                       doc.getTitle() + "_result", format));
+                                                       if ("GEOM".equals(module)) {
+                                                               // New version case
+                                                               docToCheckin.addFile(createDownloadedFile(
+                                                                               userId, doc.getTitle() + "_newvers",
+                                                                               "py"));
+                                                       } else {
+                                                               // Attached generated result case
+                                                               docToCheckin.addFile(createDownloadedFile(
+                                                                               userId, doc.getTitle() + "_result",
+                                                                               format));
+                                                       }
                                                }
                                        }
                                }