use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class UpdateDatasetThumbnailCommandTest method testDatasetNull.
@Test
public void testDatasetNull() {
dataset = null;
String expected = "Can't update dataset thumbnail. Dataset is null.";
String actual = null;
DatasetThumbnail datasetThumbnail = null;
try {
datasetThumbnail = testEngine.submit(new UpdateDatasetThumbnailCommand(null, dataset, UpdateDatasetThumbnailCommand.UserIntent.setDatasetFileAsThumbnail, 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 testSetDatasetFileAsThumbnailFileThumbnailUnexpectedlyAbsent.
@Test
public void testSetDatasetFileAsThumbnailFileThumbnailUnexpectedlyAbsent() {
String expected = "Dataset thumbnail is unexpectedly absent.";
String actual = null;
DatasetThumbnail datasetThumbnail = null;
try {
datasetThumbnail = testEngine.submit(new UpdateDatasetThumbnailCommand(null, dataset, UpdateDatasetThumbnailCommand.UserIntent.setDatasetFileAsThumbnail, thumbnailUnexpectedlyAbsent, 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 CreatePrivateUrlCommandTest method testAttemptCreatePrivateUrlOnNonDraft.
@Test
public void testAttemptCreatePrivateUrlOnNonDraft() {
dataset = new Dataset();
List<DatasetVersion> versions = new ArrayList<>();
DatasetVersion datasetVersion = new DatasetVersion();
datasetVersion.setVersionState(DatasetVersion.VersionState.RELEASED);
versions.add(datasetVersion);
dataset.setVersions(versions);
dataset.setId(latestVersionIsNotDraft);
String expected = "Can't create Private URL because the latest version of dataset id " + latestVersionIsNotDraft + " is not a draft.";
String actual = null;
PrivateUrl privateUrl = null;
try {
privateUrl = testEngine.submit(new CreatePrivateUrlCommand(null, dataset));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
assertNull(privateUrl);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class CreatePrivateUrlCommandTest method testDatasetNull.
@Test
public void testDatasetNull() {
dataset = null;
String expected = "Can't create Private URL. Dataset is null.";
String actual = null;
PrivateUrl privateUrl = null;
try {
privateUrl = testEngine.submit(new CreatePrivateUrlCommand(null, dataset));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
assertNull(privateUrl);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class AddReplaceFileHelper method step_055_loadOptionalFileParams.
/**
* Load optional file params such as description, tags, fileDataTags, etc..
*
* @param optionalFileParams
* @return
*/
private boolean step_055_loadOptionalFileParams(OptionalFileParams optionalFileParams) {
if (hasError()) {
return false;
}
// --------------------------------------------
if (optionalFileParams == null) {
return true;
}
// --------------------------------------------
for (DataFile df : finalFileList) {
try {
optionalFileParams.addOptionalParams(df);
// call restriction command here
boolean restrict = optionalFileParams.getRestriction();
if (restrict != df.getFileMetadata().isRestricted()) {
commandEngine.submit(new RestrictFileCommand(df, dvRequest, restrict));
}
} catch (DataFileTagException ex) {
Logger.getLogger(AddReplaceFileHelper.class.getName()).log(Level.SEVERE, null, ex);
addError(ex.getMessage());
return false;
} catch (CommandException ex) {
addError(ex.getMessage());
}
}
return true;
}
Aggregations