use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class ReturnDatasetToAuthorCommandTest method testAllGood.
/*
FIXME - Empty Comments won't be allowed in future
@Test
public void testEmptyComments(){
dataset.setIdentifier("DUMMY");
dataset.getLatestVersion().setVersionState(DatasetVersion.VersionState.DRAFT);
dataset.getLatestVersion().setInReview(true);
dataset.getLatestVersion().setReturnReason(null);
String expected = "You must enter a reason for returning a dataset to the author(s).";
String actual = null;
Dataset updatedDataset = null;
try {
updatedDataset = testEngine.submit(new ReturnDatasetToAuthorCommand(dataverseRequest, dataset));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
}
*/
@Test
public void testAllGood() {
dataset.getLatestVersion().setVersionState(DatasetVersion.VersionState.DRAFT);
Dataset updatedDataset = null;
try {
testEngine.submit(new AddLockCommand(dataverseRequest, dataset, new DatasetLock(DatasetLock.Reason.InReview, dataverseRequest.getAuthenticatedUser())));
updatedDataset = testEngine.submit(new ReturnDatasetToAuthorCommand(dataverseRequest, dataset, "Update Your Files, Dummy"));
} catch (CommandException ex) {
System.out.println("Error updating dataset: " + ex.getMessage());
}
assertNotNull(updatedDataset);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class ReturnDatasetToAuthorCommandTest method testReleasedDataset.
@Test
public void testReleasedDataset() {
dataset.getLatestVersion().setVersionState(DatasetVersion.VersionState.RELEASED);
// dataset.getLatestVersion().setInReview(true);
String expected = "This dataset cannot be return to the author(s) because the latest version is not In Review. The author(s) needs to click Submit for Review first.";
String actual = null;
Dataset updatedDataset = null;
try {
updatedDataset = testEngine.submit(new ReturnDatasetToAuthorCommand(dataverseRequest, dataset, ""));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class ReturnDatasetToAuthorCommandTest method testNotInReviewDataset.
@Test
public void testNotInReviewDataset() {
dataset.getLatestVersion().setVersionState(DatasetVersion.VersionState.DRAFT);
// dataset.getLatestVersion().setInReview(false);
String expected = "This dataset cannot be return to the author(s) because the latest version is not In Review. The author(s) needs to click Submit for Review first.";
String actual = null;
Dataset updatedDataset = null;
try {
updatedDataset = testEngine.submit(new ReturnDatasetToAuthorCommand(dataverseRequest, dataset, ""));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class UpdateDatasetThumbnailCommandTest method testIntentNull.
@Test
public void testIntentNull() {
String expected = "No changes to save.";
String actual = null;
DatasetThumbnail datasetThumbnail = null;
try {
datasetThumbnail = testEngine.submit(new UpdateDatasetThumbnailCommand(null, dataset, null, Long.MIN_VALUE, null));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
assertNull(datasetThumbnail);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class UpdateDatasetThumbnailCommandTest method testSetDatasetFileAsThumbnailFileNotFound.
@Test
public void testSetDatasetFileAsThumbnailFileNotFound() {
String expected = "Could not find file based on id supplied: 1.";
String actual = null;
DatasetThumbnail datasetThumbnail = null;
try {
datasetThumbnail = testEngine.submit(new UpdateDatasetThumbnailCommand(null, dataset, UpdateDatasetThumbnailCommand.UserIntent.setDatasetFileAsThumbnail, unfindableFile, null));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
assertNull(datasetThumbnail);
}
Aggregations