// Do test checkin
_scenarioService.checkin(scenarioId, userId, stepsToCheckin);
+ _scenarioDAO.flush();
// Check that scenario is no more marked as checked out
aScen = _scenarioDAO.get(scenarioId);
Assert.assertFalse(aScen.isCheckedout(),
private FileDTO createDownloadedFile(final long userId, final String name,
final String format) throws IOException {
// Create a file in the download directory
- String filePath = getDownloadPath(userId) + name + "." + format;
+ return createDownloadedFile(userId, name + "." + format);
+ }
+
+ /**
+ * Create a file in the user's repository downloads directory.
+ *
+ * @param userId
+ * user id
+ * @param fname
+ * file name
+ * @return created file DTO
+ * @throws IOException
+ * if file creation failed
+ */
+ private FileDTO createDownloadedFile(final long userId, final String fname)
+ throws IOException {
+ // Create a file in the download directory
+ String filePath = getDownloadPath(userId) + fname;
FileWriter fw = new FileWriter(filePath);
- fw.write("Simulation of " + name + "." + format
- + " file for checkin at " + new Date());
+ fw.write("Simulation of " + fname + " file for checkin at "
+ + new Date());
fw.close();
return new FileDTO(filePath);
}
} else {
dprop.setFormat("py");
}
+ dprop.setLocalPath(dprop.getName() + "." + dprop.getFormat());
Publication pub = createDoc(aScenario, aScStep, dprop, "med",
false);
if (usedPub != null) {
// Create another document with outdated publication
dprop.setName("document" + i++).setType(dtype).setFormat("py");
+ dprop.setLocalPath(dprop.getName() + "." + dprop.getFormat());
createDoc(aScenario, aScStep, dprop, "med", true);
}
// document<i>: document type[0] - first type used on the step
// <source-file>.brep
// <attached-file>.med
+ createDownloadedFile(aScenario.getAuthor().getIndex(), dprop
+ .getLocalPath());
Publication pub = _stepService.createDocument(aScStep, dprop);
Assert.assertNotNull(pub.getOwner(),
"The publication must be attached to the scenario.");
ht.saveOrUpdate(pub);
// Attach a file
+ createDownloadedFile(aScenario.getAuthor().getIndex(), dprop
+ .getLocalPath().substring(0,
+ dprop.getLocalPath().lastIndexOf(".") - 1),
+ attachedFileExt);
ht.save(pub.value());
ht.saveOrUpdate(_publicationService.attach(pub, attachedFileExt));