Search in sources :

Example 31 with Dataverse

use of edu.harvard.iq.dataverse.Dataverse 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 32 with Dataverse

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

the class MoveDataverseCommandTest method setUp.

@Before
public void setUp() {
    root = new Dataverse();
    root.setName("root");
    root.setId(1l);
    childA = new Dataverse();
    childA.setName("childA");
    childA.setId(2l);
    childB = new Dataverse();
    childB.setName("childB");
    childB.setId(3l);
    grandchildAA = new Dataverse();
    grandchildAA.setName("grandchildAA");
    grandchildAA.setId(4l);
    childA.setOwner(root);
    childB.setOwner(root);
    grandchildAA.setOwner(childA);
    testEngine = new TestDataverseEngine(new TestCommandContext() {

        @Override
        public DataverseServiceBean dataverses() {
            return new DataverseServiceBean() {

                @Override
                public Dataverse save(Dataverse dataverse) {
                    // no-op. The superclass accesses databases which we don't have.
                    return dataverse;
                }
            };
        }
    });
}
Also used : TestCommandContext(edu.harvard.iq.dataverse.engine.TestCommandContext) Dataverse(edu.harvard.iq.dataverse.Dataverse) DataverseServiceBean(edu.harvard.iq.dataverse.DataverseServiceBean) TestDataverseEngine(edu.harvard.iq.dataverse.engine.TestDataverseEngine) Before(org.junit.Before)

Example 33 with Dataverse

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

the class UpdatePermissionRootCommandTest method testNoChange.

@Test
public void testNoChange() throws CommandException {
    Dataverse dv = MocksFactory.makeDataverse();
    DataverseEngine ngn = new TestDataverseEngine(testCommandContext);
    dv.setPermissionRoot(false);
    UpdatePermissionRootCommand sut = new UpdatePermissionRootCommand(false, MocksFactory.makeRequest(), dv);
    Dataverse result = ngn.submit(sut);
    assertFalse(result.isPermissionRoot());
    assertFalse(serviceBeanCalled);
    dv.setPermissionRoot(true);
    sut = new UpdatePermissionRootCommand(true, MocksFactory.makeRequest(), dv);
    result = ngn.submit(sut);
    assertTrue(result.isPermissionRoot());
    assertFalse(serviceBeanCalled);
}
Also used : DataverseEngine(edu.harvard.iq.dataverse.engine.DataverseEngine) TestDataverseEngine(edu.harvard.iq.dataverse.engine.TestDataverseEngine) Dataverse(edu.harvard.iq.dataverse.Dataverse) TestDataverseEngine(edu.harvard.iq.dataverse.engine.TestDataverseEngine) Test(org.junit.Test)

Example 34 with Dataverse

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

the class UpdatePermissionRootCommandTest method testChange.

@Test
public void testChange() throws CommandException {
    Dataverse dv = MocksFactory.makeDataverse();
    DataverseEngine ngn = new TestDataverseEngine(testCommandContext);
    dv.setPermissionRoot(false);
    UpdatePermissionRootCommand sut = new UpdatePermissionRootCommand(true, MocksFactory.makeRequest(), dv);
    Dataverse result = ngn.submit(sut);
    assertTrue(result.isPermissionRoot());
    assertTrue(serviceBeanCalled);
    dv.setPermissionRoot(true);
    sut = new UpdatePermissionRootCommand(false, MocksFactory.makeRequest(), dv);
    result = ngn.submit(sut);
    assertFalse(result.isPermissionRoot());
    assertTrue(serviceBeanCalled);
}
Also used : DataverseEngine(edu.harvard.iq.dataverse.engine.DataverseEngine) TestDataverseEngine(edu.harvard.iq.dataverse.engine.TestDataverseEngine) Dataverse(edu.harvard.iq.dataverse.Dataverse) TestDataverseEngine(edu.harvard.iq.dataverse.engine.TestDataverseEngine) Test(org.junit.Test)

Example 35 with Dataverse

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

the class FileUtilTest method testIsDownloadPopupRequiredHasGuestBook.

@Test
public void testIsDownloadPopupRequiredHasGuestBook() {
    DatasetVersion datasetVersion = new DatasetVersion();
    datasetVersion.setVersionState(DatasetVersion.VersionState.RELEASED);
    Dataset dataset = new Dataset();
    datasetVersion.setDataset(dataset);
    Guestbook guestbook = new Guestbook();
    guestbook.setEnabled(true);
    dataset.setGuestbook(guestbook);
    Dataverse dataverse = new Dataverse();
    guestbook.setDataverse(dataverse);
    assertEquals(true, FileUtil.isDownloadPopupRequired(datasetVersion));
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) Guestbook(edu.harvard.iq.dataverse.Guestbook) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) Dataverse(edu.harvard.iq.dataverse.Dataverse) Test(org.junit.Test)

Aggregations

Dataverse (edu.harvard.iq.dataverse.Dataverse)94 Dataset (edu.harvard.iq.dataverse.Dataset)34 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)31 Test (org.junit.Test)27 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)22 DataFile (edu.harvard.iq.dataverse.DataFile)18 IOException (java.io.IOException)18 Path (javax.ws.rs.Path)16 JsonObject (javax.json.JsonObject)15 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)11 ArrayList (java.util.ArrayList)11 EJBException (javax.ejb.EJBException)11 JsonObjectBuilder (javax.json.JsonObjectBuilder)11 InputStream (java.io.InputStream)10 Date (java.util.Date)10 JsonArrayBuilder (javax.json.JsonArrayBuilder)10 POST (javax.ws.rs.POST)10 DataverseRole (edu.harvard.iq.dataverse.authorization.DataverseRole)9 User (edu.harvard.iq.dataverse.authorization.users.User)9 SwordError (org.swordapp.server.SwordError)9