use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class StorageIOTest method testGetDvObject.
@Test
public void testGetDvObject() {
assertEquals(null, instance.getDvObject());
instance.setDvObject(new Dataset());
assertEquals(new Dataset(), instance.getDataset());
try {
instance.getDataFile();
fail("This should have thrown");
} catch (ClassCastException ex) {
assertEquals(ex.getMessage(), "edu.harvard.iq.dataverse.Dataset cannot be cast to edu.harvard.iq.dataverse.DataFile");
}
try {
instance.getDataverse();
fail("This should have thrown");
} catch (ClassCastException ex) {
assertEquals(ex.getMessage(), "edu.harvard.iq.dataverse.Dataset cannot be cast to edu.harvard.iq.dataverse.Dataverse");
}
assertEquals(new DataFile(), new FileAccessIO<>(new DataFile()).getDataFile());
assertEquals(new Dataverse(), new FileAccessIO<>(new Dataverse()).getDataverse());
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class DatasetUtilTest method testGetThumbnailCandidates.
/**
* Test of getThumbnailCandidates method, of class DatasetUtil.
*/
@Test
public void testGetThumbnailCandidates() {
assertEquals(new ArrayList<>(), DatasetUtil.getThumbnailCandidates(null, false));
Dataset dataset = MocksFactory.makeDataset();
DataFile dataFile = MocksFactory.makeDataFile();
dataFile.setContentType("image/");
dataFile.setOwner(dataset);
dataFile.setStorageIdentifier("file://src/test/resources/images/coffeeshop.png");
System.out.println(ImageThumbConverter.isThumbnailAvailable(dataFile));
DatasetVersion version = dataset.getCreateVersion();
List<FileMetadata> fmds = new ArrayList<>();
fmds.add(MocksFactory.addFileMetadata(dataFile));
version.setFileMetadatas(fmds);
assertEquals(new ArrayList<>(), DatasetUtil.getThumbnailCandidates(dataset, false));
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class DatasetUtilTest method testIsDatasetLogoPresent.
/**
* Test of isDatasetLogoPresent method, of class DatasetUtil.
*/
@Test
public void testIsDatasetLogoPresent() {
Dataset dataset = MocksFactory.makeDataset();
assertEquals(false, DatasetUtil.isDatasetLogoPresent(dataset));
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class CreatePrivateUrlCommandTest method setUp.
@Before
public void setUp() {
dataset = new Dataset();
testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public PrivateUrlServiceBean privateUrl() {
return new PrivateUrlServiceBean() {
@Override
public PrivateUrl getPrivateUrlFromDatasetId(long datasetId) {
if (datasetId == privateUrlAlreadyExists) {
Dataset dataset = new Dataset();
dataset.setId(privateUrlAlreadyExists);
String token = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(datasetId);
RoleAssignment roleAssignment = new RoleAssignment(null, privateUrlUser, dataset, token);
return new PrivateUrl(roleAssignment, dataset, "FIXME");
} else if (datasetId == latestVersionIsNotDraft) {
return null;
} else {
return null;
}
}
};
}
@Override
public DataverseRoleServiceBean roles() {
return new DataverseRoleServiceBean() {
@Override
public DataverseRole findBuiltinRoleByAlias(String alias) {
return new DataverseRole();
}
@Override
public RoleAssignment save(RoleAssignment assignment) {
// no-op
return assignment;
}
};
}
@Override
public SystemConfig systemConfig() {
return new SystemConfig() {
@Override
public String getDataverseSiteUrl() {
return "https://dataverse.example.edu";
}
};
}
});
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class DataCaptureModuleUtilTest method testGenerateJsonForUploadRequest.
@Test
public void testGenerateJsonForUploadRequest() {
System.out.println("generateJsonForUploadRequest");
AuthenticatedUser user = makeAuthenticatedUser("Ralph", "Rsync");
Dataset dataset = new Dataset();
dataset.setIdentifier("42");
JsonObject result = DataCaptureModuleUtil.generateJsonForUploadRequest(user, dataset);
assertEquals("42", result.getString("datasetIdentifier"));
int userId = result.getInt("userId");
assertTrue(Integer.MIN_VALUE <= userId && userId <= Integer.MAX_VALUE);
}
Aggregations