use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class JsonParserTest method testParseEmptyDataset.
/**
* Expect an exception when the dataset JSON is empty.
* @throws JsonParseException when the test is broken
*/
@Test(expected = NullPointerException.class)
public void testParseEmptyDataset() throws JsonParseException {
JsonObject dsJson;
try (InputStream jsonFile = ClassLoader.getSystemResourceAsStream("json/empty-dataset.json")) {
InputStreamReader reader = new InputStreamReader(jsonFile, "UTF-8");
dsJson = Json.createReader(reader).readObject();
System.out.println(dsJson != null);
Dataset actual = sut.parseDataset(dsJson);
assertEquals("10.5072/FK2", actual.getAuthority());
assertEquals("/", actual.getDoiSeparator());
assertEquals("doi", actual.getProtocol());
} catch (IOException ioe) {
throw new JsonParseException("Couldn't read test file", ioe);
}
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetPrivateUrlUserFromRoleAssignmentAndAssigneeNonPrivateUrlUser.
@Test
public void testGetPrivateUrlUserFromRoleAssignmentAndAssigneeNonPrivateUrlUser() {
DataverseRole aRole = null;
RoleAssignee assignee = GuestUser.get();
DvObject dataset = new Dataset();
String privateUrlToken = "cd71e9d7-73a7-4ec8-b890-3d00499e8693";
RoleAssignment assignment = new RoleAssignment(aRole, assignee, dataset, privateUrlToken);
PrivateUrlUser privateUrl = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(assignment, assignee);
assertNull(privateUrl);
}
use of edu.harvard.iq.dataverse.Dataset 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());
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDraftUrlSuccess.
@Test
public void testGetDraftUrlSuccess() throws Exception {
DatasetVersion draft = new DatasetVersion();
Dataset dataset = new Dataset();
dataset.setProtocol("doi");
dataset.setAuthority("10.5072/FK2");
dataset.setIdentifier("3L33T");
draft.setDataset(dataset);
assertEquals("/dataset.xhtml?persistentId=doi:10.5072/FK2/3L33T&version=DRAFT", PrivateUrlUtil.getDraftUrl(draft));
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetPrivateUrlRedirectDataFail.
@Test
public void testGetPrivateUrlRedirectDataFail() {
DataverseRole aRole = null;
long datasetId = 42;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(datasetId);
RoleAssignee anAssignee = privateUrlUser;
Dataset dataset = new Dataset();
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
ra.setDefinitionPoint(null);
PrivateUrlRedirectData privateUrlRedirectData = null;
privateUrlRedirectData = PrivateUrlUtil.getPrivateUrlRedirectData(ra);
assertNull(privateUrlRedirectData);
}
Aggregations