Search in sources :

Example 6 with DvObject

use of edu.harvard.iq.dataverse.DvObject in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetDraftDatasetVersionFromRoleAssignmentNullDataset.

@Test
public void testGetDraftDatasetVersionFromRoleAssignmentNullDataset() {
    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);
    DatasetVersion datasetVersion = PrivateUrlUtil.getDraftDatasetVersionFromRoleAssignment(ra);
    assertNull(datasetVersion);
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 7 with DvObject

use of edu.harvard.iq.dataverse.DvObject in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetPrivateUrlFromRoleAssignmentSuccess.

@Test
public void testGetPrivateUrlFromRoleAssignmentSuccess() {
    String dataverseSiteUrl = "https://dataverse.example.edu";
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUser;
    DvObject dataset = new Dataset();
    dataset.setId(42l);
    String privateUrlToken = "cd71e9d7-73a7-4ec8-b890-3d00499e8693";
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
    PrivateUrl privateUrl = PrivateUrlUtil.getPrivateUrlFromRoleAssignment(ra, dataverseSiteUrl);
    assertNotNull(privateUrl);
    assertEquals(new Long(42), privateUrl.getDataset().getId());
    assertEquals("https://dataverse.example.edu/privateurl.xhtml?token=cd71e9d7-73a7-4ec8-b890-3d00499e8693", privateUrl.getLink());
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) Dataset(edu.harvard.iq.dataverse.Dataset) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 8 with DvObject

use of edu.harvard.iq.dataverse.DvObject in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetUserFromRoleAssignmentNonDataset.

@Test
public void testGetUserFromRoleAssignmentNonDataset() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUserIn = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUserIn;
    DvObject nonDataset = new Dataverse();
    nonDataset.setId(123l);
    String privateUrlToken = null;
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, nonDataset, privateUrlToken);
    PrivateUrlUser privateUrlUserOut = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(ra);
    assertNull(privateUrlUserOut);
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) Dataverse(edu.harvard.iq.dataverse.Dataverse) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 9 with DvObject

use of edu.harvard.iq.dataverse.DvObject in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetDatasetFromRoleAssignmentNonDataset.

@Test
public void testGetDatasetFromRoleAssignmentNonDataset() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUser;
    DvObject nonDataset = new Dataverse();
    String privateUrlToken = null;
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, nonDataset, privateUrlToken);
    assertNull(PrivateUrlUtil.getDatasetFromRoleAssignment(ra));
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) Dataverse(edu.harvard.iq.dataverse.Dataverse) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 10 with DvObject

use of edu.harvard.iq.dataverse.DvObject in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetUserFromRoleAssignmentSucess.

@Test
public void testGetUserFromRoleAssignmentSucess() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUserIn = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUserIn;
    DvObject dataset = new Dataset();
    dataset.setId(123l);
    String privateUrlToken = null;
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
    PrivateUrlUser privateUrlUserOut = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(ra);
    assertNotNull(privateUrlUserOut);
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) Dataset(edu.harvard.iq.dataverse.Dataset) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Aggregations

DvObject (edu.harvard.iq.dataverse.DvObject)32 Dataset (edu.harvard.iq.dataverse.Dataset)16 RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)14 DataverseRole (edu.harvard.iq.dataverse.authorization.DataverseRole)12 RoleAssignee (edu.harvard.iq.dataverse.authorization.RoleAssignee)12 PrivateUrlUser (edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 Dataverse (edu.harvard.iq.dataverse.Dataverse)8 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)7 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)7 IOException (java.io.IOException)6 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)5 DataFile (edu.harvard.iq.dataverse.DataFile)4 DatasetVersionUser (edu.harvard.iq.dataverse.DatasetVersionUser)4 Permission (edu.harvard.iq.dataverse.authorization.Permission)4 User (edu.harvard.iq.dataverse.authorization.users.User)4 Timestamp (java.sql.Timestamp)4 HashMap (java.util.HashMap)4 DatasetField (edu.harvard.iq.dataverse.DatasetField)3