use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDraftDatasetVersionFromRoleAssignmentLastestIsNotDraft.
@Test
public void testGetDraftDatasetVersionFromRoleAssignmentLastestIsNotDraft() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
Dataset dataset = new Dataset();
List<DatasetVersion> versions = new ArrayList<>();
DatasetVersion datasetVersionIn = new DatasetVersion();
datasetVersionIn.setVersionState(DatasetVersion.VersionState.RELEASED);
versions.add(datasetVersionIn);
dataset.setVersions(versions);
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
DatasetVersion datasetVersionOut = PrivateUrlUtil.getDraftDatasetVersionFromRoleAssignment(ra);
assertNull(datasetVersionOut);
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDatasetFromRoleAssignmentNullDefinitionPoint.
@Test
public void testGetDatasetFromRoleAssignmentNullDefinitionPoint() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
DvObject nullDefinitionPoint = null;
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, nullDefinitionPoint, privateUrlToken);
assertNull(PrivateUrlUtil.getDatasetFromRoleAssignment(ra));
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetPrivateUrlFromRoleAssignmentDatasetNull.
@Test
public void testGetPrivateUrlFromRoleAssignmentDatasetNull() {
String dataverseSiteUrl = "https://dataverse.example.edu";
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
DvObject dataset = null;
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
PrivateUrl privateUrl = PrivateUrlUtil.getPrivateUrlFromRoleAssignment(ra, dataverseSiteUrl);
assertNull(privateUrl);
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDatasetFromRoleAssignmentSuccess.
@Test
public void testGetDatasetFromRoleAssignmentSuccess() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
DvObject dataset = new Dataset();
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
assertNotNull(PrivateUrlUtil.getDatasetFromRoleAssignment(ra));
assertEquals("#42", ra.getAssigneeIdentifier());
}
use of edu.harvard.iq.dataverse.authorization.DataverseRole in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetPrivateUrlRedirectDataSuccess.
@Test
public void testGetPrivateUrlRedirectDataSuccess() {
DataverseRole aRole = null;
long datasetId = 42;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(datasetId);
RoleAssignee anAssignee = privateUrlUser;
Dataset dataset = new Dataset();
dataset.setProtocol("doi");
dataset.setAuthority("10.5072/FK2");
dataset.setIdentifier("3L33T");
dataset.setId(datasetId);
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
PrivateUrlRedirectData privateUrlRedirectData = PrivateUrlUtil.getPrivateUrlRedirectData(ra);
assertNotNull(privateUrlRedirectData);
assertEquals("/dataset.xhtml?persistentId=doi:10.5072/FK2/3L33T&version=DRAFT", privateUrlRedirectData.getDraftDatasetPageToBeRedirectedTo());
assertEquals(privateUrlUser.getIdentifier(), privateUrlRedirectData.getPrivateUrlUser().getIdentifier());
}
Aggregations