use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class MocksFactory method makeDataset.
public static Dataset makeDataset() {
Dataset ds = new Dataset();
ds.setId(nextId());
ds.setIdentifier("sample-ds-" + ds.getId());
ds.setCategoriesByName(Arrays.asList("CatOne", "CatTwo", "CatThree"));
final List<DataFile> files = makeFiles(10);
final List<FileMetadata> metadatas = new ArrayList<>(10);
final List<DataFileCategory> categories = ds.getCategories();
Random rand = new Random();
files.forEach(df -> {
df.getFileMetadata().addCategory(categories.get(rand.nextInt(categories.size())));
metadatas.add(df.getFileMetadata());
});
ds.setFiles(files);
final DatasetVersion initialVersion = ds.getVersions().get(0);
initialVersion.setFileMetadatas(metadatas);
List<DatasetField> fields = new ArrayList<>();
DatasetField field = new DatasetField();
field.setId(nextId());
field.setSingleValue("Sample Field Value");
field.setDatasetFieldType(makeDatasetFieldType());
fields.add(field);
initialVersion.setDatasetFields(fields);
ds.setOwner(makeDataverse());
return ds;
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class GetPrivateUrlCommandTest method testDatasetWithoutAnId.
@Test
public void testDatasetWithoutAnId() throws Exception {
dataset = new Dataset();
PrivateUrl privateUrl = testEngine.submit(new GetPrivateUrlCommand(null, dataset));
assertNull(privateUrl);
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class GetLatestPublishedDatasetVersionCommandTest method testLatestPublishedNoDraft.
@Test
public void testLatestPublishedNoDraft() throws CommandException {
Dataset ds = MocksFactory.makeDataset();
List<DatasetVersion> versions = make10Versions(ds);
ds.setVersions(versions);
assertEquals(10l, engine.submit(new GetLatestPublishedDatasetVersionCommand(makeRequest(), ds)).getVersionNumber().longValue());
assertTrue("Published datasets should require no permissions to view", engine.getReqiredPermissionsForObjects().get(ds).isEmpty());
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class GetLatestPublishedDatasetVersionCommandTest method testLatestPublishedWithDraft.
@Test
public void testLatestPublishedWithDraft() throws CommandException {
Dataset ds = MocksFactory.makeDataset();
List<DatasetVersion> versions = make10Versions(ds);
versions.add(MocksFactory.makeDatasetVersion(ds.getCategories()));
ds.setVersions(versions);
assertEquals(10l, engine.submit(new GetLatestPublishedDatasetVersionCommand(makeRequest(), ds)).getVersionNumber().longValue());
assertTrue("Published datasets should require no permissions to view", engine.getReqiredPermissionsForObjects().get(ds).isEmpty());
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class GetLatestPublishedDatasetVersionCommandTest method testLatestNonePublished.
@Test
public void testLatestNonePublished() throws CommandException {
Dataset ds = MocksFactory.makeDataset();
assertNull(engine.submit(new GetLatestPublishedDatasetVersionCommand(makeRequest(), ds)));
}
Aggregations