Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/ReviewsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static jakarta.ws.rs.core.Response.Status.CREATED;
import static jakarta.ws.rs.core.Response.Status.OK;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.IOException;
Expand Down Expand Up @@ -231,6 +232,23 @@ public void testCreateReview() {
Integer reviewId = UtilIT.getDatasetIdFromResponse(createReview);
String reviewPid = JsonPath.from(createReview.getBody().asString()).getString("data.persistentId");

UtilIT.publishDataverseViaNativeApi(dataverseAlias, apiToken).then().statusCode(OK.getStatusCode());
UtilIT.publishDatasetViaNativeApi(reviewPid, "major", apiToken).then().statusCode(OK.getStatusCode());

/**
* Review datasets are "inside out" in the sense that we don't present the
* normal metadata fields via Croissant. Instead, we attempt to represent the
* item being reviewed. The number of fields we can expose is limited, but we
* can expose "itemReviewedUrl" as "url" for example.
*/
Response insideOutCroissant = UtilIT.exportDataset(reviewPid, "croissantSlim");
insideOutCroissant.prettyPrint();
insideOutCroissant.then().assertThat()
.statusCode(OK.getStatusCode())
.body("@type", is("sc:Dataset"))
.body("name", nullValue())
.body("url", is("https://datacommons.org/tools/statvar#sv=Percent_Person_Children_WithAsthma"));

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class CroissantExporterSlimTest {
static ExportDataProvider dataProviderJunk;
static OutputStream outputStreamDraft;
static ExportDataProvider dataProviderDraft;
static OutputStream outputStreamReview;
static ExportDataProvider dataProviderReview;

@BeforeAll
public static void setUp() {
Expand Down Expand Up @@ -430,6 +432,70 @@ public String getDataCiteXml() {
}
}
};

outputStreamReview = new ByteArrayOutputStream();
dataProviderReview =
new ExportDataProvider() {
@Override
public JsonObject getDatasetJson() {
String pathToJsonFile =
"src/test/resources/croissant/review/in/datasetJson.json";
try (JsonReader jsonReader =
Json.createReader(new FileReader(pathToJsonFile))) {
return jsonReader.readObject();
} catch (FileNotFoundException ex) {
return null;
}
}

@Override
public JsonObject getDatasetORE() {
String pathToJsonFile =
"src/test/resources/croissant/review/in/datasetORE.json";
try (JsonReader jsonReader =
Json.createReader(new FileReader(pathToJsonFile))) {
return jsonReader.readObject();
} catch (FileNotFoundException ex) {
return null;
}
}

@Override
public JsonArray getDatasetFileDetails() {
String pathToJsonFile =
"src/test/resources/croissant/review/in/datasetFileDetails.json";
try (JsonReader jsonReader =
Json.createReader(new FileReader(pathToJsonFile))) {
return jsonReader.readArray();
} catch (FileNotFoundException ex) {
return null;
}
}

@Override
public JsonObject getDatasetSchemaDotOrg() {
String pathToJsonFile =
"src/test/resources/croissant/review/in/datasetSchemaDotOrg.json";
try (JsonReader jsonReader =
Json.createReader(new FileReader(pathToJsonFile))) {
return jsonReader.readObject();
} catch (FileNotFoundException ex) {
return null;
}
}

@Override
public String getDataCiteXml() {
try {
return Files.readString(
Paths.get(
"src/test/resources/croissant/review/in/dataCiteXml.xml"),
StandardCharsets.UTF_8);
} catch (IOException ex) {
return null;
}
}
};
}

@Test
Expand Down Expand Up @@ -544,6 +610,20 @@ public void testExportDatasetDraft() throws Exception {
assertEquals(prettyPrint(expected), prettyPrint(outputStreamDraft.toString()));
}

@Test
public void testExportDatasetReview() throws Exception {
exporter.exportDataset(dataProviderReview, outputStreamReview);
String actual = outputStreamReview.toString();
writeCroissantFile(actual, "review");
String expected =
Files.readString(
Paths.get(
"src/test/resources/croissant/review/expected/review-croissantSlim.json"),
StandardCharsets.UTF_8);
JSONAssert.assertEquals(expected, actual, true);
assertEquals(prettyPrint(expected), prettyPrint(outputStreamReview.toString()));
}

private void writeCroissantFile(String actual, String name) throws IOException {
Path dir =
Files.createDirectories(Paths.get("src/test/resources/croissant/" + name + "/out"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"@context": {
"@language": "en",
"@vocab": "http://schema.org/",
"citeAs": "cr:citeAs",
"column": "cr:column",
"conformsTo": "dct:conformsTo",
"cr": "http://mlcommons.org/croissant/",
"rai": "http://mlcommons.org/croissant/RAI/",
"data": {
"@id": "cr:data",
"@type": "@json"
},
"dataType": {
"@id": "cr:dataType",
"@type": "@vocab"
},
"dct": "http://purl.org/dc/terms/",
"ddi-stats": "http://rdf-vocabulary.ddialliance.org/cv/SummaryStatisticType/2.1.2/",
"examples": {
"@id": "cr:examples",
"@type": "@json"
},
"extract": "cr:extract",
"field": "cr:field",
"fileProperty": "cr:fileProperty",
"fileObject": "cr:fileObject",
"fileSet": "cr:fileSet",
"format": "cr:format",
"includes": "cr:includes",
"isLiveDataset": "cr:isLiveDataset",
"jsonPath": "cr:jsonPath",
"key": "cr:key",
"md5": "cr:md5",
"parentField": "cr:parentField",
"path": "cr:path",
"recordSet": "cr:recordSet",
"references": "cr:references",
"regex": "cr:regex",
"repeated": "cr:repeated",
"replace": "cr:replace",
"samplingRate": "cr:samplingRate",
"sc": "http://schema.org/",
"separator": "cr:separator",
"source": "cr:source",
"subField": "cr:subField",
"transform": "cr:transform"
},
"@type": "sc:Dataset",
"conformsTo": "http://mlcommons.org/croissant/1.1",
"url": "https://datacommons.org/tools/statvar#sv=Percent_Person_Children_WithAsthma"
}
31 changes: 31 additions & 0 deletions src/test/resources/croissant/review/in/dataCiteXml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<resource xmlns="http://datacite.org/schema/kernel-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.5/metadata.xsd">
<identifier identifierType="DOI">10.5072/FK2/ZIKBUC</identifier>
<creators>
<creator>
<creatorName nameType="Personal">Wazowski, Mike</creatorName>
<givenName>Mike</givenName>
<familyName>Wazowski</familyName>
</creator>
</creators>
<titles>
<title>Review of Percent of Children That Have Asthma</title>
</titles>
<publisher>Root</publisher>
<publicationYear>2026</publicationYear>
<subjects>
<subject>Medicine, Health and Life Sciences</subject>
</subjects>
<dates>
<date dateType="Available">2026-03-13</date>
</dates>
<resourceType resourceTypeGeneral="Other">Review</resourceType>
<version>1.0</version>
<rightsList>
<rights rightsURI="info:eu-repo/semantics/openAccess"/>
<rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0" rightsIdentifier="CC0-1.0" rightsIdentifierScheme="SPDX" schemeURI="https://spdx.org/licenses/" xml:lang="en">Creative Commons CC0 1.0 Universal Public Domain Dedication.</rights>
</rightsList>
<descriptions>
<description descriptionType="Abstract">This is a review of a dataset.</description>
</descriptions>
</resource>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
140 changes: 140 additions & 0 deletions src/test/resources/croissant/review/in/datasetJson.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"id": 3,
"identifier": "FK2/ZIKBUC",
"persistentUrl": "https://doi.org/10.5072/FK2/ZIKBUC",
"protocol": "doi",
"authority": "10.5072",
"separator": "/",
"publisher": "Root",
"publicationDate": "2026-03-13",
"storageIdentifier": "local://10.5072/FK2/ZIKBUC",
"datasetType": "review",
"locks": [],
"datasetVersion": {
"id": 1,
"datasetId": 3,
"datasetPersistentId": "doi:10.5072/FK2/ZIKBUC",
"datasetType": "review",
"storageIdentifier": "local://10.5072/FK2/ZIKBUC",
"versionNumber": 1,
"internalVersionNumber": 4,
"versionMinorNumber": 0,
"versionState": "RELEASED",
"latestVersionPublishingState": "RELEASED",
"lastUpdateTime": "2026-03-13T20:30:58Z",
"releaseTime": "2026-03-13T20:30:58Z",
"createTime": "2026-03-13T20:30:56Z",
"publicationDate": "2026-03-13",
"citationDate": "2026-03-13",
"license": {
"name": "CC0 1.0",
"uri": "http://creativecommons.org/publicdomain/zero/1.0",
"iconUri": "https://licensebuttons.net/p/zero/1.0/88x31.png",
"rightsIdentifier": "CC0-1.0",
"rightsIdentifierScheme": "SPDX",
"schemeUri": "https://spdx.org/licenses/",
"languageCode": "en"
},
"fileAccessRequest": true,
"metadataBlocks": {
"citation": {
"displayName": "Citation Metadata",
"name": "citation",
"fields": [
{
"typeName": "title",
"multiple": false,
"typeClass": "primitive",
"value": "Review of Percent of Children That Have Asthma"
},
{
"typeName": "author",
"multiple": true,
"typeClass": "compound",
"value": [
{
"authorName": {
"typeName": "authorName",
"multiple": false,
"typeClass": "primitive",
"value": "Wazowski, Mike"
}
}
]
},
{
"typeName": "datasetContact",
"multiple": true,
"typeClass": "compound",
"value": [
{
"datasetContactEmail": {
"typeName": "datasetContactEmail",
"multiple": false,
"typeClass": "primitive",
"value": "mwazowski@mailinator.com"
}
}
]
},
{
"typeName": "dsDescription",
"multiple": true,
"typeClass": "compound",
"value": [
{
"dsDescriptionValue": {
"typeName": "dsDescriptionValue",
"multiple": false,
"typeClass": "primitive",
"value": "This is a review of a dataset."
}
}
]
},
{
"typeName": "subject",
"multiple": true,
"typeClass": "controlledVocabulary",
"value": [
"Medicine, Health and Life Sciences"
]
}
]
},
"review": {
"displayName": "Review Metadata",
"name": "review",
"fields": [
{
"typeName": "itemReviewed",
"multiple": false,
"typeClass": "compound",
"value": {
"itemReviewedUrl": {
"typeName": "itemReviewedUrl",
"multiple": false,
"typeClass": "primitive",
"value": "https://datacommons.org/tools/statvar#sv=Percent_Person_Children_WithAsthma"
},
"itemReviewedType": {
"typeName": "itemReviewedType",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "Dataset"
},
"itemReviewedCitation": {
"typeName": "itemReviewedCitation",
"multiple": false,
"typeClass": "primitive",
"value": "\"Statistical Variable Explorer - Data Commons.\" Datacommons.org, 2026, datacommons.org/tools/statvar#sv=Percent_Person_Children_WithAsthma. Accessed 9 Mar. 2026."
}
}
}
]
}
},
"files": [],
"citation": "Wazowski, Mike, 2026, \"Review of Percent of Children That Have Asthma\", https://doi.org/10.5072/FK2/ZIKBUC, Root, V1"
}
}
Loading
Loading