use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDraftUrlNoGlobalId.
@Test
public void testGetDraftUrlNoGlobalId() throws Exception {
DatasetVersion draft = new DatasetVersion();
Dataset dataset = new Dataset();
draft.setDataset(dataset);
assertEquals("UNKNOWN", PrivateUrlUtil.getDraftUrl(draft));
}
use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.
the class GetLatestPublishedDatasetVersionCommandTest method make10Versions.
private List<DatasetVersion> make10Versions(Dataset ds) {
// setup: make 10 versions.
List<DatasetVersion> versions = new ArrayList<>(10);
for (int i = 10; i > 0; i--) {
DatasetVersion v = MocksFactory.makeDatasetVersion(ds.getCategories());
v.setVersionNumber((long) i);
v.setMinorVersionNumber(0l);
v.setReleaseTime(MocksFactory.date(1990, i, 1));
v.setVersionState(DatasetVersion.VersionState.RELEASED);
versions.add(v);
}
return versions;
}
use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.
the class DatasetUtilTest method testGetThumbnailNullDataset.
@Test
public void testGetThumbnailNullDataset() {
assertNull(DatasetUtil.getThumbnail(null));
assertNull(DatasetUtil.getThumbnail(null, null));
Dataset dataset = MocksFactory.makeDataset();
dataset.setStorageIdentifier("file://");
dataset.setUseGenericThumbnail(true);
assertNull(DatasetUtil.getThumbnail(dataset));
assertNull(DatasetUtil.getThumbnail(dataset, new DatasetVersion()));
}
use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.
the class CreateDatasetVersionCommandTest method testSimpleVersionAddition.
@Test
public void testSimpleVersionAddition() throws Exception {
SimpleDateFormat dateFmt = new SimpleDateFormat("yyyyMMdd");
// Create Dataset
Dataset ds = makeDataset();
// Populate the Initial version
DatasetVersion dsvInitial = ds.getEditVersion();
dsvInitial.setCreateTime(dateFmt.parse("20001012"));
dsvInitial.setLastUpdateTime(dsvInitial.getLastUpdateTime());
dsvInitial.setId(MocksFactory.nextId());
dsvInitial.setReleaseTime(dateFmt.parse("20010101"));
dsvInitial.setVersionState(DatasetVersion.VersionState.RELEASED);
dsvInitial.setMinorVersionNumber(0l);
dsvInitial.setVersionNumber(1l);
// Create version to be added
DatasetVersion dsvNew = new DatasetVersion();
dsvNew.setVersionState(DatasetVersion.VersionState.DRAFT);
// Execute
CreateDatasetVersionCommand sut = new CreateDatasetVersionCommand(makeRequest(), ds, dsvNew);
final MockDatasetServiceBean serviceBean = new MockDatasetServiceBean();
TestDataverseEngine testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public DatasetServiceBean datasets() {
return serviceBean;
}
});
testEngine.submit(sut);
// asserts
assertTrue(serviceBean.storeVersionCalled);
Date dsvCreationDate = dsvNew.getCreateTime();
assertEquals(dsvCreationDate, dsvNew.getLastUpdateTime());
assertEquals(dsvCreationDate.getTime(), ds.getModificationTime().getTime());
assertEquals(ds, dsvNew.getDataset());
assertEquals(dsvNew, ds.getEditVersion());
Map<DvObject, Set<Permission>> expected = new HashMap<>();
expected.put(ds, Collections.singleton(Permission.AddDataset));
assertEquals(expected, testEngine.getReqiredPermissionsForObjects());
}
use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.
the class CreateDatasetVersionCommandTest method testCantCreateTwoDraftVersions.
@Test(expected = IllegalCommandException.class)
public void testCantCreateTwoDraftVersions() throws Exception {
DatasetVersion dsvNew = new DatasetVersion();
dsvNew.setVersionState(DatasetVersion.VersionState.DRAFT);
// Execute
CreateDatasetVersionCommand sut = new CreateDatasetVersionCommand(makeRequest(), makeDataset(), dsvNew);
TestDataverseEngine testEngine = new TestDataverseEngine(new TestCommandContext());
testEngine.submit(sut);
}
Aggregations