Search in sources :

Example 51 with Dataset

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

the class RepositoryStorageAbstractionLayerUtilTest method testGetRsalSites_3args.

@Test
public void testGetRsalSites_3args() {
    System.out.println("getRsalSites");
    Dataset dataset = new Dataset();
    dataset.setIdentifier("identifierPartOfPersistentID");
    dataset.setAuthority("10.5072/FK2");
    String replicationSitesInDB = "dv.sbgrid.org:Harvard Medical School:USA,sbgrid.icm.uu.se:Uppsala University:Sweden,sbgrid.ncpss.org:Institut Pasteur de Montevideo:Uruguay,sbgrid.ncpss.org:Shanghai Institutes for Biological Sciences:China";
    JsonArray myList = RepositoryStorageAbstractionLayerUtil.getSitesFromDb(replicationSitesInDB);
    List<RsyncSite> result = RepositoryStorageAbstractionLayerUtil.getRsyncSites(dataset, myList);
    System.out.println(result.get(0).getName());
    assertEquals("Harvard Medical School", result.get(0).getName());
    assertEquals("USA", result.get(0).getCountry());
    assertEquals("dv.sbgrid.org", result.get(0).getFqdn());
    assertEquals("10.5072/FK2/identifierPartOfPersistentID", result.get(0).getFullRemotePathToDirectory());
    assertEquals("rsync -av rsync://dv.sbgrid.org/10.5072/FK2/identifierPartOfPersistentID", result.get(0).getRsyncDownloadcommand());
}
Also used : JsonArray(javax.json.JsonArray) Dataset(edu.harvard.iq.dataverse.Dataset) Test(org.junit.Test)

Example 52 with Dataset

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

the class SubmitDatasetForReviewCommandTest method testDatasetNull.

@Test
public void testDatasetNull() {
    dataset = null;
    String expected = "Can't submit for review. Dataset is null.";
    String actual = null;
    Dataset updatedDataset = null;
    try {
        updatedDataset = testEngine.submit(new SubmitDatasetForReviewCommand(dataverseRequest, dataset));
    } catch (CommandException ex) {
        actual = ex.getMessage();
    }
    assertEquals(expected, actual);
    assertNull(updatedDataset);
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) Test(org.junit.Test)

Example 53 with Dataset

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

the class SubmitDatasetForReviewCommandTest method testDraftDataset.

@Test
public void testDraftDataset() {
    dataset.getLatestVersion().setVersionState(DatasetVersion.VersionState.DRAFT);
    Dataset updatedDataset = null;
    try {
        updatedDataset = testEngine.submit(new SubmitDatasetForReviewCommand(dataverseRequest, dataset));
    } catch (CommandException ex) {
        System.out.println("Error updating dataset: " + ex.getMessage());
    }
    assertNotNull(updatedDataset);
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) Test(org.junit.Test)

Example 54 with Dataset

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

the class PrivateUrlUtilTest method testGetPrivateUrlUserFromRoleAssignmentAndAssigneeSuccess.

@Test
public void testGetPrivateUrlUserFromRoleAssignmentAndAssigneeSuccess() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
    RoleAssignee assignee = privateUrlUser;
    DvObject dataset = new Dataset();
    dataset.setId(42l);
    String privateUrlToken = "cd71e9d7-73a7-4ec8-b890-3d00499e8693";
    RoleAssignment assignment = new RoleAssignment(aRole, assignee, dataset, privateUrlToken);
    PrivateUrlUser privateUrl = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(assignment, assignee);
    assertNotNull(privateUrl);
}
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 55 with Dataset

use of edu.harvard.iq.dataverse.Dataset 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

Dataset (edu.harvard.iq.dataverse.Dataset)142 Test (org.junit.Test)53 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)44 DataFile (edu.harvard.iq.dataverse.DataFile)41 Dataverse (edu.harvard.iq.dataverse.Dataverse)34 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)27 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)23 IOException (java.io.IOException)22 ArrayList (java.util.ArrayList)22 Path (javax.ws.rs.Path)22 FileMetadata (edu.harvard.iq.dataverse.FileMetadata)17 DataverseRole (edu.harvard.iq.dataverse.authorization.DataverseRole)17 RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)16 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)16 Date (java.util.Date)16 JsonObjectBuilder (javax.json.JsonObjectBuilder)16 JsonObject (javax.json.JsonObject)15 DvObject (edu.harvard.iq.dataverse.DvObject)14 RoleAssignee (edu.harvard.iq.dataverse.authorization.RoleAssignee)14 PrivateUrlUser (edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser)14