Assert.assertEquals(doc.getTitle(), docName);
Assert.assertNotNull(doc.getFiles(),
"Document files list must not be null.");
- Assert.assertTrue(doc.getFiles().size() > 1,
- "Document must have more then 1 attached file.");
+ Assert
+ .assertTrue(doc.getFiles().size() > 1,
+ "Document must have more then 1 attached file.");
for (FileDTO file : doc.getFiles()) {
Assert.assertNotNull(file.getPath(),
} else { // Outdated
Assert.assertEquals(file.getState(), 'O',
"File state must be outdated ('O').");
- Assert.assertEquals(file.getProcessing(),
- "file-download",
- "Outdated document should not be imported but downloaded.");
+ Assert
+ .assertEquals(file.getProcessing(),
+ "file-download",
+ "Outdated document should not be imported but downloaded.");
}
}
}
try {
steps = _scenarioService.getScenarioInfo(-1L);
// getHibernateTemplate().flush();
- Assert.fail("Getting an object with not existing id must be failed.");
+ Assert
+ .fail("Getting an object with not existing id must be failed.");
} catch (Exception e) {
LOG.debug("Expected exception is thrown: "
+ e.getClass().getSimpleName() + ": " + e.getMessage());
* <li>presentation of the previous version is removed</li>
* <li>uses relations are copied correctly</li>
* <li>files are moved correctly</li>
+ * <li>formats of files are new if they are according to the document's type on the study step</li>
* <li>new documents are created for new data</li>
* <li>new documents have correctly generated names</li>
* <li>uses relations are created correctly</li>
}
}
}
- Assert.assertTrue(
- found,
+ Assert.assertTrue(found,
"New version of the existing checked in document \""
+ docDTO.getTitle() + "\" (id="
+ docDTO.getId()
// Check that presentation of the previous version is removed
Assert.assertFalse(aScen.publishes(prevDoc));
checkFiles(docDTO, newPub);
+
+ // Formats of files are new if they are according to the document's type on the study step
+ if ("py".equals(prevDoc.getFormat())
+ && "geometry".equals(prevDoc.getType().getName())) {
+ Assert.assertEquals(newPub.value().getFormat(), "brep");
+ Assert.assertEquals(newPub.getSourceFile().getFormat(),
+ "brep");
+ Assert.assertEquals(newPub.getSourceFile()
+ .getRelativePath().substring(
+ newPub.getSourceFile()
+ .getRelativePath().lastIndexOf(
+ '.') + 1), "brep");
+ }
+
// Check that uses relations are copied correctly
// 1. Get all uses relations of the previous document version
.getSourceFile().asFile());
found = fcontent.contains(docDTO.getTitle());
if (found) {
- LOG.debug("Found new document with generated title: "
- + pub.value().getTitle());
+ LOG
+ .debug("Found new document with generated title: "
+ + pub.value().getTitle());
newPub = pub;
break;
}
Assert.assertTrue(found,
"New document is not created for checked in document \""
+ docDTO.getTitle() + "\".");
+
// Check that uses relations are created correctly
- Assert.assertTrue(
- newPub.value()
- .getTitle()
- .startsWith(
- newPub.value().getType().getName()
- + "_"),
+ Assert.assertTrue(newPub.value().getTitle().startsWith(
+ newPub.value().getType().getName() + "_"),
"Document title newPub.value().getTitle() must start with "
+ newPub.value().getType().getName() + "_");
// Call checkin method for a not existing id.
try {
_scenarioService.checkin(-1, userId, stepsToCheckin);
- Assert.fail("Check in for scenario with not existing id must be failed.");
+ Assert
+ .fail("Check in for scenario with not existing id must be failed.");
} catch (Exception e) {
LOG.debug("Expected exception is thrown: "
+ e.getClass().getSimpleName() + ": " + e.getMessage());
String format = fileDTO.getPath().substring(
fileDTO.getPath().lastIndexOf('.') + 1);
}
- // TODO:Check file by its internal content
+ // TODO: Check file by its internal content
Assert.assertTrue(newPub.getSourceFile().exists(), "File "
+ newPub.getSourceFile().asFile().getAbsolutePath()
+ " for the document " + docDTO.getTitle()
DocumentDTO docToCheckin = stepToCheckin.addDoc(
doc.getId(), doc.getTitle());
for (FileDTO file : doc.getFiles()) {
- if (file.getPath().endsWith(format)) {
+ if (file.getPath().endsWith(format)
+ || (file.getPath().endsWith("py") && format
+ .equals("brep"))) {
// Create a file in the download directory
docToCheckin.addFile(createDownloadedFile(userId,
doc.getTitle() + "_result", format));
}
// Prepare new data
stepToCheckin.addDoc(0, "newdoc" + stepFrom.getNumber()).addFile(
- createDownloadedFile(userId,
- "newdoc" + stepFrom.getNumber(), "brep"));
+ createDownloadedFile(userId, "newdoc"
+ + stepFrom.getNumber(), "brep"));
}
return stepToCheckin;
}
// Prepare download directory
File tmpDir = _repositoryService.getDownloadDirectory(userId);
if (!tmpDir.exists()) {
- Assert.assertTrue(
- tmpDir.mkdir(),
+ Assert.assertTrue(tmpDir.mkdir(),
"Can't create temporary directory: "
+ tmpDir.getAbsolutePath());
}
User.Properties uprop = new User.Properties();
uprop.setUsername("TST_Username").setName("TST_SimanUnitTestsUser")
.setFirstName("TST_FirstName").setDisplayName("TST_test.user")
- .addRole("TST_user")
- .setMailAddress("noreply@salome-platform.org");
+ .addRole("TST_user").setMailAddress(
+ "noreply@salome-platform.org");
uprop.disableCheck();
User anAuthor = new User(uprop);
ht.saveOrUpdate(anAuthor);
// Create a test study
- Study.Properties stprops = new Study.Properties()
- .setReference("TST_SID_01").setTitle("TST_Study")
- .setManager(anAuthor);
+ Study.Properties stprops = new Study.Properties().setReference(
+ "TST_SID_01").setTitle("TST_Study").setManager(anAuthor);
Study aStudy = new Study(stprops);
ht.saveOrUpdate(aStudy);
// Create a test scenario
- Scenario.Properties sprops = new Scenario.Properties()
- .setTitle("TST_Scenario").setManager(anAuthor)
- .setOwnerStudy(aStudy);
+ Scenario.Properties sprops = new Scenario.Properties().setTitle(
+ "TST_Scenario").setManager(anAuthor).setOwnerStudy(aStudy);
Scenario aScenario = new Scenario(sprops);
aStudy.getScenariiList().add(aScenario);
ht.saveOrUpdate(anAuthor);
if (step.getNumber() > 3) {
dprop.setFormat("med");
} else {
- dprop.setFormat("brep");
+ dprop.setFormat("py");
}
Publication pub = createDoc(aScenario, aScStep, dprop, "med",
false);
usedPub = pub;
// Create another document with outdated publication
- dprop.setName("document" + i++).setType(dtype)
- .setFormat("brep");
+ dprop.setName("document" + i++).setType(dtype).setFormat("py");
createDoc(aScenario, aScStep, dprop, "med", true);
}
Assert.assertTrue(ht.find("from Document").size() > 0,
"No documents in the database.");
- Assert.assertNotNull(
- ht.find("from Publication where owner=" + aScenario.getIndex()),
- "No publications in the database.");
+ Assert.assertNotNull(ht.find("from Publication where owner="
+ + aScenario.getIndex()), "No publications in the database.");
Assert.assertTrue(
ht.find("from Publication where owner=" + aScenario.getIndex())
.size() > 0, "No publications in the database.");
"More then one document must be in the database");
// Check created uses relations
- Assert.assertTrue(usedMap.size() > 0, "Uses relations must be created.");
+ Assert
+ .assertTrue(usedMap.size() > 0,
+ "Uses relations must be created.");
boolean foundAny = false;
for (Long usingId : usedMap.keySet()) {
for (Publication pub : aScen.getDocums()) {
User.Properties uprop = new User.Properties();
uprop.setUsername("TST_Username").setName("TST_SimanUnitTestsUser")
.setFirstName("TST_FirstName").setDisplayName("TST_test.user")
- .addRole("TST_user")
- .setMailAddress("noreply@salome-platform.org");
+ .addRole("TST_user").setMailAddress(
+ "noreply@salome-platform.org");
uprop.disableCheck();
User anAuthor = new User(uprop);
"Knowledge type 'usecase' must be created in the database.");
SimulationContextType prodtype = _simulationContextService
.selectType("product");
- Assert.assertNotNull(prodtype,
- "Simulation context type 'product' must be created in the database.");
+ Assert
+ .assertNotNull(prodtype,
+ "Simulation context type 'product' must be created in the database.");
// Create admin
uprop.clear();
uprop.setUsername("TST_Admin").setName("TST_SimanUnitTestsAdmin")
- .setFirstName("TST_AdminFirstName")
- .setDisplayName("TST_test.admin").addRole("TST_user,sysadmin")
+ .setFirstName("TST_AdminFirstName").setDisplayName(
+ "TST_test.admin").addRole("TST_user,sysadmin")
.setMailAddress("noreply@salome-platform.org");
uprop.disableCheck();