diff --git a/conf/solr/schema.xml b/conf/solr/schema.xml
index 2aed50e9998..d5c789c7189 100644
--- a/conf/solr/schema.xml
+++ b/conf/solr/schema.xml
@@ -234,6 +234,7 @@
+
-
-
\ No newline at end of file
+
diff --git a/src/main/webapp/previewurl.xhtml b/src/main/webapp/previewurl.xhtml
new file mode 100644
index 00000000000..980d775506b
--- /dev/null
+++ b/src/main/webapp/previewurl.xhtml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/mydata.js b/src/main/webapp/resources/js/mydata.js
index 899ba6637e2..c731d6772ac 100644
--- a/src/main/webapp/resources/js/mydata.js
+++ b/src/main/webapp/resources/js/mydata.js
@@ -391,7 +391,7 @@ function submit_my_data_search(){
// --------------------------------
// ah, but with the horribly coded xhtml page, we can't use form tags...
//var formData = $('#mydata_filter_form').serialize();
- var formData = $("#my_data_filter_column :input").serialize() + '&' + $("#my_data_filter_column2 :input").serialize() ;
+ var formData = $("#my_data_filter_column :input").serialize() + '&' + $("#my_data_filter_column3 :input").serialize()+ '&' + $("#my_data_filter_column2 :input").serialize() ;
// For debugging, show the search params
if (MYDATA_DEBUG_ON){
diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java
index a235c9b0061..588bf5294e5 100644
--- a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java
+++ b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java
@@ -63,17 +63,17 @@ public void testIsSanitizeHtml() {
//if textbox then sanitize - allow tags
instance.setFieldType(DatasetFieldType.FieldType.TEXTBOX);
result = instance.isSanitizeHtml();
- assertEquals(true, result);
+ assertTrue(result);
//if textbox then don't sanitize - allow tags
instance.setFieldType(DatasetFieldType.FieldType.EMAIL);
result = instance.isSanitizeHtml();
- assertEquals(false, result);
+ assertFalse(result);
//URL, too
instance.setFieldType(DatasetFieldType.FieldType.URL);
result = instance.isSanitizeHtml();
- assertEquals(true, result);
+ assertTrue(result);
}
@Test
@@ -102,7 +102,7 @@ public void testIsEscapeOutputText(){
//URL, too
instance.setFieldType(DatasetFieldType.FieldType.URL);
result = instance.isEscapeOutputText();
- assertEquals(false, result);
+ assertFalse(result);
}
@@ -121,7 +121,7 @@ public void testGetSolrField(){
parent.setAllowMultiples(true);
instance.setParentDatasetFieldType(parent);
solrField = instance.getSolrField();
- assertEquals(true, solrField.isAllowedToBeMultivalued());
+ assertTrue(solrField.isAllowedToBeMultivalued());
}
diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValueValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValueValidatorTest.java
index 3f85acc1f87..b753f534c6b 100644
--- a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValueValidatorTest.java
+++ b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValueValidatorTest.java
@@ -52,63 +52,63 @@ public void testIsValid() {
//Make string too long - should fail.
value.setValue("asdfgX");
result = instance.isValid(value, ctx);
- assertEquals(false, result);
+ assertFalse(result);
//Make string too long - should fail.
value.setValue("asdf");
result = instance.isValid(value, ctx);
- assertEquals(false, result);
+ assertFalse(result);
//Now lets try Dates
dft.setFieldType(DatasetFieldType.FieldType.DATE);
dft.setValidationFormat(null);
value.setValue("1999AD");
result = instance.isValid(value, ctx);
- assertEquals(true, result);
+ assertTrue(result);
value.setValue("44BCE");
result = instance.isValid(value, ctx);
- assertEquals(true, result);
+ assertTrue(result);
value.setValue("2004-10-27");
result = instance.isValid(value, ctx);
- assertEquals(true, result);
+ assertTrue(result);
value.setValue("2002-08");
result = instance.isValid(value, ctx);
- assertEquals(true, result);
+ assertTrue(result);
value.setValue("[1999?]");
result = instance.isValid(value, ctx);
- assertEquals(true, result);
+ assertTrue(result);
value.setValue("Blergh");
result = instance.isValid(value, ctx);
- assertEquals(false, result);
+ assertFalse(result);
//Float
dft.setFieldType(DatasetFieldType.FieldType.FLOAT);
value.setValue("44");
result = instance.isValid(value, ctx);
- assertEquals(true, result);
+ assertTrue(result);
value.setValue("44 1/2");
result = instance.isValid(value, ctx);
- assertEquals(false, result);
+ assertFalse(result);
//Integer
dft.setFieldType(DatasetFieldType.FieldType.INT);
value.setValue("44");
result = instance.isValid(value, ctx);
- assertEquals(true, result);
+ assertTrue(result);
value.setValue("-44");
result = instance.isValid(value, ctx);
- assertEquals(true, result);
+ assertTrue(result);
value.setValue("12.14");
result = instance.isValid(value, ctx);
- assertEquals(false, result);
+ assertFalse(result);
}
@Test
diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionDifferenceTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionDifferenceTest.java
index 8508c9ac34e..0ba8dde8aa0 100644
--- a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionDifferenceTest.java
+++ b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionDifferenceTest.java
@@ -1,11 +1,10 @@
package edu.harvard.iq.dataverse;
-import edu.harvard.iq.dataverse.DatasetVersionDifference.datasetFileDifferenceItem;
-import edu.harvard.iq.dataverse.DatasetVersionDifference.datasetReplaceFileItem;
import edu.harvard.iq.dataverse.branding.BrandingUtilTest;
import edu.harvard.iq.dataverse.datavariable.VariableMetadata;
import edu.harvard.iq.dataverse.datavariable.VariableMetadataUtil;
import edu.harvard.iq.dataverse.license.License;
+import edu.harvard.iq.dataverse.pidproviders.doi.AbstractDOIProvider;
import edu.harvard.iq.dataverse.util.BundleUtil;
import java.net.URI;
@@ -17,7 +16,15 @@
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;
+
+import static org.assertj.core.util.DateUtil.now;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import edu.harvard.iq.dataverse.util.json.JsonUtil;
+import io.restassured.path.json.JsonPath;
+import jakarta.json.JsonObject;
+import jakarta.json.JsonObjectBuilder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
@@ -31,6 +38,7 @@ public class DatasetVersionDifferenceTest {
private static List changedFileMetadata;
private static List changedVariableMetadata;
private static List replacedFiles;
+ private static Long fileId = Long.valueOf(0);
@BeforeAll
public static void setUp() {
@@ -276,7 +284,7 @@ private static void originalCalculateDifference(DatasetVersion newVersion, Datas
for (FileMetadata fmdn : newVersion.getFileMetadatas()) {
if (fmdo.getDataFile().equals(fmdn.getDataFile())) {
deleted = false;
- if (!DatasetVersionDifference.compareFileMetadatas(fmdo, fmdn)) {
+ if (!DatasetVersionDifference.compareFileMetadatas(fmdo, fmdn).isEmpty()) {
changedFileMetadata.add(fmdo);
changedFileMetadata.add(fmdn);
}
@@ -346,4 +354,107 @@ private static void getReplacedFiles() {
});
}
}
+
+ @Test
+ public void testCompareVersionsAsJson() {
+
+ Dataverse dv = new Dataverse();
+ Dataset ds = new Dataset();
+ ds.setOwner(dv);
+ ds.setGlobalId(new GlobalId(AbstractDOIProvider.DOI_PROTOCOL,"10.5072","FK2/BYM3IW", "/", AbstractDOIProvider.DOI_RESOLVER_URL, null));
+
+ DatasetVersion dv1 = initDatasetVersion(0L, ds, DatasetVersion.VersionState.RELEASED);
+ DatasetVersion dv2 = initDatasetVersion(1L, ds, DatasetVersion.VersionState.DRAFT);
+ ds.setVersions(List.of(dv1, dv2));
+
+ TermsOfUseAndAccess toa = new TermsOfUseAndAccess();
+ toa.setDisclaimer("disclaimer");
+ dv2.setTermsOfUseAndAccess(toa);
+ DatasetField dsf = new DatasetField();
+ dsf.setDatasetFieldType(new DatasetFieldType("Author", DatasetFieldType.FieldType.TEXT, true));
+ MetadataBlock mb = new MetadataBlock();
+ mb.setDisplayName("testMetadataBlock");
+ dsf.getDatasetFieldType().setMetadataBlock(mb);
+ dsf.setSingleValue("TEST");
+ dv2.getDatasetFields().add(dsf);
+ // modify file at index 0
+ dv2.getFileMetadatas().get(0).setRestricted(!dv2.getFileMetadatas().get(2).isRestricted());
+
+ FileMetadata addedFile = initFile(dv2); // add a new file
+ FileMetadata removedFile = dv2.getFileMetadatas().get(1); // remove the second file
+ dv2.getFileMetadatas().remove(1);
+ FileMetadata replacedFile = dv2.getFileMetadatas().get(1); // the third file is now at index 1 since the second file was removed
+ FileMetadata replacementFile = initFile(dv2, replacedFile.getDataFile().getId()); // replace the third file with a new file
+ dv2.getFileMetadatas().remove(1);
+
+ DatasetVersionDifference dvd = new DatasetVersionDifference(dv2, dv1);
+
+ JsonObjectBuilder json = dvd.compareVersionsAsJson();
+ JsonObject obj = json.build();
+ System.out.println(JsonUtil.prettyPrint(obj));
+
+ JsonPath dataFile = JsonPath.from(JsonUtil.prettyPrint(obj));
+ assertTrue("TEST".equalsIgnoreCase(dataFile.getString("metadataChanges[0].changed[0].newValue")));
+ assertTrue(addedFile.getLabel().equalsIgnoreCase(dataFile.getString("filesAdded[0].fileName")));
+ assertTrue(removedFile.getLabel().equalsIgnoreCase(dataFile.getString("filesRemoved[0].fileName")));
+ assertTrue(replacedFile.getLabel().equalsIgnoreCase(dataFile.getString("filesReplaced[0].oldFile.fileName")));
+ assertTrue(replacementFile.getLabel().equalsIgnoreCase(dataFile.getString("filesReplaced[0].newFile.fileName")));
+ assertTrue("true".equalsIgnoreCase(dataFile.getString("fileChanges[0].changed[0].newValue")));
+ assertTrue("disclaimer".equalsIgnoreCase(dataFile.getString("TermsOfAccess.changed[0].newValue")));
+ }
+ private DatasetVersion initDatasetVersion(Long id, Dataset ds, DatasetVersion.VersionState vs) {
+ DatasetVersion dv = new DatasetVersion();
+ dv.setDataset(ds);
+ dv.setVersion(1L);
+ dv.setVersionState(vs);
+ dv.setMinorVersionNumber(0L);
+ if (vs == DatasetVersion.VersionState.RELEASED) {
+ dv.setVersionNumber(1L);
+ dv.setVersion(1L);
+ dv.setReleaseTime(now());
+ }
+ dv.setId(id);
+ dv.setCreateTime(now());
+ dv.setLastUpdateTime(now());
+ dv.setTermsOfUseAndAccess(new TermsOfUseAndAccess());
+ dv.setFileMetadatas(initFiles(dv));
+ return dv;
+ }
+ private List initFiles(DatasetVersion dsv) {
+ List fileMetadatas = new ArrayList<>();
+ fileId = 0L;
+ for (int i=0; i < 10; i++) {
+ FileMetadata fm = initFile(dsv);
+ fileMetadatas.add(fm);
+ }
+ return fileMetadatas;
+ }
+ private FileMetadata initFile(DatasetVersion dsv) {
+ return initFile(dsv, null);
+ }
+ private FileMetadata initFile(DatasetVersion dsv, Long prevId) {
+ Long id = fileId++;
+ FileMetadata fm = new FileMetadata();
+ DataFile df = new DataFile();
+ fm.setDatasetVersion(dsv);
+ DataTable dt = new DataTable();
+ dt.setOriginalFileName("filename"+id+".txt");
+ df.setId(id);
+ df.setDescription("Desc"+id);
+ df.setRestricted(false);
+ df.setFilesize(100 + id);
+ df.setChecksumType(DataFile.ChecksumType.MD5);
+ df.setChecksumValue("value"+id);
+ df.setDataTable(dt);
+ df.setOwner(dsv.getDataset());
+ df.getFileMetadatas().add(fm);
+ df.setPreviousDataFileId(prevId);
+ fm.setId(id);
+ fm.setDataFile(df);
+ fm.setLabel("Label"+id);
+ fm.setDirectoryLabel("/myFilePath/");
+ fm.setDescription("Desc"+id);
+ dsv.getFileMetadatas().add(fm);
+ return fm;
+ }
}
diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java
index 4cd6c4dfaa7..b36d8907472 100644
--- a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java
+++ b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java
@@ -80,7 +80,7 @@ public void testIsInReview() {
DatasetVersion nonDraft = new DatasetVersion();
nonDraft.setVersionState(DatasetVersion.VersionState.RELEASED);
- assertEquals(false, nonDraft.isInReview());
+ assertFalse(nonDraft.isInReview());
ds.addLock(null);
assertFalse(nonDraft.isInReview());
diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
index 10584f2df71..34afbb404f0 100644
--- a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
+++ b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
@@ -1676,7 +1676,7 @@ public void testPrivateUrl() {
List assignments = with(roleAssignments.body().asString()).param("member", "member").getJsonObject("data.findAll { data -> data._roleAlias == member }");
assertEquals(1, assignments.size());
PrivateUrlUser privateUrlUser = new PrivateUrlUser(datasetId);
- assertEquals("Private URL Enabled", privateUrlUser.getDisplayInfo().getTitle());
+ assertEquals("Preview URL Enabled", privateUrlUser.getDisplayInfo().getTitle());
List assigneeShouldExistForPrivateUrlUser = with(roleAssignments.body().asString()).param("assigneeString", privateUrlUser.getIdentifier()).getJsonObject("data.findAll { data -> data.assignee == assigneeString }");
logger.info(assigneeShouldExistForPrivateUrlUser + " found for " + privateUrlUser.getIdentifier());
assertEquals(1, assigneeShouldExistForPrivateUrlUser.size());
@@ -1757,7 +1757,7 @@ public void testPrivateUrl() {
Response privateUrlRoleAssignmentShouldBeGoneAfterDraftDeleted = UtilIT.getRoleAssignmentsOnDataset(datasetId.toString(), null, apiToken);
privateUrlRoleAssignmentShouldBeGoneAfterDraftDeleted.prettyPrint();
- assertEquals(false, privateUrlRoleAssignmentShouldBeGoneAfterDraftDeleted.body().asString().contains(privateUrlUser.getIdentifier()));
+ assertFalse(privateUrlRoleAssignmentShouldBeGoneAfterDraftDeleted.body().asString().contains(privateUrlUser.getIdentifier()));
String newTitleAgain = "I am changing the title again";
Response draftCreatedAgainPostPub = UtilIT.updateDatasetTitleViaSword(dataset1PersistentId, newTitleAgain, apiToken);
@@ -5168,4 +5168,134 @@ public void testGetCanDownloadAtLeastOneFile() {
Response getUserPermissionsOnDatasetInvalidIdResponse = UtilIT.getCanDownloadAtLeastOneFile("testInvalidId", DS_VERSION_LATEST, secondUserApiToken);
getUserPermissionsOnDatasetInvalidIdResponse.then().assertThat().statusCode(BAD_REQUEST.getStatusCode());
}
+
+ @Test
+ public void testCompareDatasetVersionsAPI() throws InterruptedException {
+
+ Response createUser = UtilIT.createRandomUser();
+ assertEquals(200, createUser.getStatusCode());
+ String username = UtilIT.getUsernameFromResponse(createUser);
+ String apiToken = UtilIT.getApiTokenFromResponse(createUser);
+ Response makeSuperUser = UtilIT.makeSuperUser(username);
+ assertEquals(200, makeSuperUser.getStatusCode());
+
+ Response createDataverseResponse = UtilIT.createRandomDataverse(apiToken);
+ String dataverseAlias = UtilIT.getAliasFromResponse(createDataverseResponse);
+
+ Response createDatasetResponse = UtilIT.createRandomDatasetViaNativeApi(dataverseAlias, apiToken);
+ Integer datasetId = JsonPath.from(createDatasetResponse.body().asString()).getInt("data.id");
+
+ Response getDatasetJsonBeforePublishing = UtilIT.nativeGet(datasetId, apiToken);
+ String protocol = JsonPath.from(getDatasetJsonBeforePublishing.getBody().asString()).getString("data.protocol");
+ String authority = JsonPath.from(getDatasetJsonBeforePublishing.getBody().asString()).getString("data.authority");
+ String identifier = JsonPath.from(getDatasetJsonBeforePublishing.getBody().asString()).getString("data.identifier");
+ String datasetPersistentId = protocol + ":" + authority + "/" + identifier;
+ // used for all added files
+ JsonObjectBuilder json = Json.createObjectBuilder()
+ .add("description", "my description")
+ .add("directoryLabel", "/data/subdir1/")
+ .add("categories", Json.createArrayBuilder()
+ .add("Data")
+ );
+ JsonObject jsonObj = json.build();
+ String pathToFile = "src/main/webapp/resources/images/dataverse-icon-1200.png";
+ Response uploadResponse = UtilIT.uploadFileViaNative(String.valueOf(datasetId), pathToFile, jsonObj, apiToken);
+ uploadResponse.prettyPrint();
+ uploadResponse.then().assertThat()
+ .statusCode(OK.getStatusCode());
+ Integer modifyFileId = UtilIT.getDataFileIdFromResponse(uploadResponse);
+ pathToFile = "src/main/webapp/resources/images/dataverseproject_logo.jpg";
+ uploadResponse = UtilIT.uploadFileViaNative(String.valueOf(datasetId), pathToFile, jsonObj, apiToken);
+ uploadResponse.then().assertThat()
+ .statusCode(OK.getStatusCode());
+ Integer deleteFileId = UtilIT.getDataFileIdFromResponse(uploadResponse);
+
+ pathToFile = "src/main/webapp/resources/images/fav/favicon-16x16.png";
+ uploadResponse = UtilIT.uploadFileViaNative(String.valueOf(datasetId), pathToFile, jsonObj, apiToken);
+ uploadResponse.then().assertThat()
+ .statusCode(OK.getStatusCode());
+ Integer replaceFileId = UtilIT.getDataFileIdFromResponse(uploadResponse);
+
+ Response publishDataverse = UtilIT.publishDataverseViaSword(dataverseAlias, apiToken);
+ assertEquals(200, publishDataverse.getStatusCode());
+
+ Response publishDataset = UtilIT.publishDatasetViaNativeApi(datasetPersistentId, "major", apiToken);
+ assertEquals(200, publishDataset.getStatusCode());
+
+ // post publish update to create DRAFT version
+ String pathToJsonFilePostPub = "doc/sphinx-guides/source/_static/api/dataset-add-metadata-after-pub.json";
+ Response addDataToPublishedVersion = UtilIT.addDatasetMetadataViaNative(datasetPersistentId, pathToJsonFilePostPub, apiToken);
+ addDataToPublishedVersion.then().assertThat().statusCode(OK.getStatusCode());
+
+ // Test adding a file
+ pathToFile = "src/test/resources/tab/test.tab";
+ Response uploadTabularFileResponse = UtilIT.uploadFileViaNative(Integer.toString(datasetId), pathToFile, jsonObj, apiToken);
+ uploadTabularFileResponse.prettyPrint();
+ uploadTabularFileResponse.then().assertThat()
+ .statusCode(OK.getStatusCode());
+ Integer addedFileId = UtilIT.getDataFileIdFromResponse(uploadTabularFileResponse);
+
+ // Ensure tabular file is ingested
+ sleep(2000);
+
+ String tabularTagName = "Survey";
+ Response setFileTabularTagsResponse = UtilIT.setFileTabularTags(String.valueOf(addedFileId), apiToken, List.of(tabularTagName));
+ setFileTabularTagsResponse.prettyPrint();
+ setFileTabularTagsResponse.then().assertThat()
+ .statusCode(OK.getStatusCode());
+
+ // Test removing a file
+ uploadResponse = UtilIT.deleteFile(deleteFileId, apiToken);
+ uploadResponse.prettyPrint();
+ uploadResponse.then().assertThat()
+ .statusCode(NO_CONTENT.getStatusCode());
+
+ // Test Replacing a file
+ Response replaceResponse = UtilIT.replaceFile(String.valueOf(replaceFileId), "src/main/webapp/resources/images/fav/favicon-32x32.png", jsonObj, apiToken);
+ replaceResponse.prettyPrint();
+ replaceResponse.then().assertThat()
+ .statusCode(OK.getStatusCode());
+
+ // Test modify by restricting the file
+ Response restrictResponse = UtilIT.restrictFile(modifyFileId.toString(), true, apiToken);
+ restrictResponse.prettyPrint();
+ restrictResponse.then().assertThat()
+ .statusCode(OK.getStatusCode());
+
+ // Also test a terms of access change
+ String jsonLDTerms = "{\"https://dataverse.org/schema/core#fileTermsOfAccess\":{\"https://dataverse.org/schema/core#dataAccessPlace\":\"Somewhere\"}}";
+ Response updateTerms = UtilIT.updateDatasetJsonLDMetadata(datasetId, apiToken, jsonLDTerms, true);
+ updateTerms.then().assertThat()
+ .statusCode(OK.getStatusCode());
+
+ Response compareResponse = UtilIT.compareDatasetVersions(datasetPersistentId, ":latest-published", ":draft", apiToken);
+ compareResponse.prettyPrint();
+ compareResponse.then().assertThat()
+ .body("data.oldVersion.versionNumber", CoreMatchers.equalTo("1.0"))
+ .body("data.newVersion.versionNumber", CoreMatchers.equalTo("DRAFT"))
+ .body("data.metadataChanges[0].blockName", CoreMatchers.equalTo("Citation Metadata"))
+ .body("data.metadataChanges[0].changed[0].fieldName", CoreMatchers.equalTo("Author"))
+ .body("data.metadataChanges[0].changed[0].oldValue", CoreMatchers.containsString("Finch, Fiona; (Birds Inc.)"))
+ .body("data.metadataChanges[1].blockName", CoreMatchers.equalTo("Life Sciences Metadata"))
+ .body("data.metadataChanges[1].changed[0].fieldName", CoreMatchers.equalTo("Design Type"))
+ .body("data.metadataChanges[1].changed[0].oldValue", CoreMatchers.containsString(""))
+ .body("data.metadataChanges[1].changed[0].newValue", CoreMatchers.containsString("Parallel Group Design; Nested Case Control Design"))
+ .body("data.filesAdded[0].fileName", CoreMatchers.equalTo("test.tab"))
+ .body("data.filesAdded[0].filePath", CoreMatchers.equalTo("data/subdir1"))
+ .body("data.filesAdded[0].description", CoreMatchers.equalTo("my description"))
+ .body("data.filesAdded[0].tags[0]", CoreMatchers.equalTo("Survey"))
+ .body("data.filesRemoved[0].fileName", CoreMatchers.equalTo("dataverseproject_logo.jpg"))
+ .body("data.fileChanges[0].fileName", CoreMatchers.equalTo("dataverse-icon-1200.png"))
+ .body("data.fileChanges[0].changed[0].newValue", CoreMatchers.equalTo("true"))
+ .body("data.filesReplaced[0].oldFile.fileName", CoreMatchers.equalTo("favicon-16x16.png"))
+ .body("data.filesReplaced[0].newFile.fileName", CoreMatchers.equalTo("favicon-32x32.png"))
+ .body("data.TermsOfAccess", CoreMatchers.notNullValue())
+ .statusCode(OK.getStatusCode());
+
+ compareResponse = UtilIT.compareDatasetVersions(datasetPersistentId, ":draft", ":latest-published", apiToken);
+ compareResponse.prettyPrint();
+ compareResponse.then().assertThat()
+ .body("message", CoreMatchers.equalTo(BundleUtil.getStringFromBundle("dataset.version.compare.incorrect.order")))
+ .statusCode(BAD_REQUEST.getStatusCode());
+ }
}
diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java
index 9567cf3910a..76bb515beb2 100644
--- a/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java
+++ b/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java
@@ -1379,6 +1379,48 @@ public void testUpdateDataverse() {
Response getDataverseResponse = UtilIT.listDataverseFacets(oldDataverseAlias, apiToken);
getDataverseResponse.then().assertThat().statusCode(NOT_FOUND.getStatusCode());
+ // Update the dataverse without setting metadata blocks, facets, or input levels
+ updateDataverseResponse = UtilIT.updateDataverse(
+ newAlias,
+ newAlias,
+ newName,
+ newAffiliation,
+ newDataverseType,
+ newContactEmails,
+ null,
+ null,
+ null,
+ apiToken
+ );
+ updateDataverseResponse.then().assertThat().statusCode(OK.getStatusCode());
+
+ // Assert that the metadata blocks are inherited from the parent
+ listMetadataBlocksResponse = UtilIT.listMetadataBlocks(newAlias, false, false, apiToken);
+ listMetadataBlocksResponse
+ .then().assertThat()
+ .statusCode(OK.getStatusCode())
+ .body("data.size()", equalTo(1))
+ .body("data[0].name", equalTo("citation"));
+
+ // Assert that the facets are inherited from the parent
+ String[] rootFacetIds = new String[]{"authorName", "subject", "keywordValue", "dateOfDeposit"};
+ listDataverseFacetsResponse = UtilIT.listDataverseFacets(newAlias, apiToken);
+ String actualFacetName1 = listDataverseFacetsResponse.then().extract().path("data[0]");
+ String actualFacetName2 = listDataverseFacetsResponse.then().extract().path("data[1]");
+ String actualFacetName3 = listDataverseFacetsResponse.then().extract().path("data[2]");
+ String actualFacetName4 = listDataverseFacetsResponse.then().extract().path("data[3]");
+ assertThat(rootFacetIds, hasItemInArray(actualFacetName1));
+ assertThat(rootFacetIds, hasItemInArray(actualFacetName2));
+ assertThat(rootFacetIds, hasItemInArray(actualFacetName3));
+ assertThat(rootFacetIds, hasItemInArray(actualFacetName4));
+
+ // Assert that the dataverse should not have any input level
+ listDataverseInputLevelsResponse = UtilIT.listDataverseInputLevels(newAlias, apiToken);
+ listDataverseInputLevelsResponse
+ .then().assertThat()
+ .statusCode(OK.getStatusCode())
+ .body("data.size()", equalTo(0));
+
// Should return error when the dataverse to edit does not exist
updateDataverseResponse = UtilIT.updateDataverse(
"unexistingDataverseAlias",
diff --git a/src/test/java/edu/harvard/iq/dataverse/api/InfoIT.java b/src/test/java/edu/harvard/iq/dataverse/api/InfoIT.java
index 5e436dd0e98..b198d2769a0 100644
--- a/src/test/java/edu/harvard/iq/dataverse/api/InfoIT.java
+++ b/src/test/java/edu/harvard/iq/dataverse/api/InfoIT.java
@@ -6,11 +6,14 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST;
import static jakarta.ws.rs.core.Response.Status.NOT_FOUND;
import static jakarta.ws.rs.core.Response.Status.OK;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Paths;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
+import org.skyscreamer.jsonassert.JSONAssert;
public class InfoIT {
@@ -81,6 +84,22 @@ public void testGetZipDownloadLimit() {
.body("data", notNullValue());
}
+ @Test
+ public void testGetExportFormats() throws IOException {
+ Response response = given().urlEncodingEnabled(false)
+ .get("/api/info/exportFormats");
+ response.prettyPrint();
+ response.then().assertThat().statusCode(OK.getStatusCode());
+
+ String actual = response.getBody().asString();
+ String expected =
+ java.nio.file.Files.readString(
+ Paths.get("src/test/resources/json/export-formats.json"),
+ StandardCharsets.UTF_8);
+ JSONAssert.assertEquals(expected, actual, true);
+
+ }
+
private void testSettingEndpoint(SettingsServiceBean.Key settingKey, String testSettingValue) {
String endpoint = "/api/info/settings/" + settingKey;
diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SavedSearchIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SavedSearchIT.java
index 90357596c25..08ebec31cd6 100644
--- a/src/test/java/edu/harvard/iq/dataverse/api/SavedSearchIT.java
+++ b/src/test/java/edu/harvard/iq/dataverse/api/SavedSearchIT.java
@@ -22,7 +22,7 @@ public class SavedSearchIT {
@BeforeAll
public static void setUpClass() {
-
+ RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();
}
@AfterAll
@@ -53,81 +53,55 @@ public void testSavedSearches() {
Integer datasetId2 = UtilIT.getDatasetIdFromResponse(createDatasetResponse2);
// missing body
- Response resp = RestAssured.given()
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ Response resp = UtilIT.setSavedSearch();
resp.prettyPrint();
resp.then().assertThat()
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode());
// creatorId null
- resp = RestAssured.given()
- .body(createSavedSearchJson("*", null, dataverseId, "subject_ss:Medicine, Health and Life Sciences"))
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ resp = UtilIT.setSavedSearch(createSavedSearchJson("*", null, dataverseId, "subject_ss:Medicine, Health and Life Sciences"));
resp.prettyPrint();
resp.then().assertThat()
.statusCode(BAD_REQUEST.getStatusCode());
// creatorId string
- resp = RestAssured.given()
- .body(createSavedSearchJson("*", "1", dataverseId.toString(), "subject_ss:Medicine, Health and Life Sciences"))
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ resp = UtilIT.setSavedSearch(createSavedSearchJson("*", "1", dataverseId.toString(), "subject_ss:Medicine, Health and Life Sciences"));
resp.prettyPrint();
resp.then().assertThat()
.statusCode(BAD_REQUEST.getStatusCode());
// creatorId not found
- resp = RestAssured.given()
- .body(createSavedSearchJson("*", 9999, dataverseId, "subject_ss:Medicine, Health and Life Sciences"))
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ resp = UtilIT.setSavedSearch(createSavedSearchJson("*", 9999, dataverseId, "subject_ss:Medicine, Health and Life Sciences"));
resp.prettyPrint();
resp.then().assertThat()
.statusCode(NOT_FOUND.getStatusCode());
// definitionPointId null
- resp = RestAssured.given()
- .body(createSavedSearchJson("*", 1, null, "subject_ss:Medicine, Health and Life Sciences"))
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ resp = UtilIT.setSavedSearch(createSavedSearchJson("*", 1, null, "subject_ss:Medicine, Health and Life Sciences"));
resp.prettyPrint();
resp.then().assertThat()
.statusCode(BAD_REQUEST.getStatusCode());
// definitionPointId string
- resp = RestAssured.given()
- .body(createSavedSearchJson("*", "1", "9999", "subject_ss:Medicine, Health and Life Sciences"))
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ resp = UtilIT.setSavedSearch(createSavedSearchJson("*", "1", "9999", "subject_ss:Medicine, Health and Life Sciences"));
resp.prettyPrint();
resp.then().assertThat()
.statusCode(BAD_REQUEST.getStatusCode());
// definitionPointId not found
- resp = RestAssured.given()
- .body(createSavedSearchJson("*", 1, 9999, "subject_ss:Medicine, Health and Life Sciences"))
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ resp = UtilIT.setSavedSearch(createSavedSearchJson("*", 1, 9999, "subject_ss:Medicine, Health and Life Sciences"));
resp.prettyPrint();
resp.then().assertThat()
.statusCode(NOT_FOUND.getStatusCode());
// missing filter
- resp = RestAssured.given()
- .body(createSavedSearchJson("*", 1, dataverseId))
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ resp = UtilIT.setSavedSearch(createSavedSearchJson("*", 1, dataverseId));
resp.prettyPrint();
resp.then().assertThat()
.statusCode(OK.getStatusCode());
// create a saved search as superuser : OK
- resp = RestAssured.given()
- .body(createSavedSearchJson("*", 1, dataverseId, "subject_ss:Medicine, Health and Life Sciences"))
- .contentType("application/json")
- .post("/api/admin/savedsearches");
+ resp = UtilIT.setSavedSearch(createSavedSearchJson("*", 1, dataverseId, "subject_ss:Medicine, Health and Life Sciences"));
resp.prettyPrint();
resp.then().assertThat()
.statusCode(OK.getStatusCode());
@@ -136,8 +110,7 @@ public void testSavedSearches() {
Integer createdSavedSearchId = path.getInt("data.id");
// get list as non superuser : OK
- Response getListReponse = RestAssured.given()
- .get("/api/admin/savedsearches/list");
+ Response getListReponse = UtilIT.getSavedSearchList();
getListReponse.prettyPrint();
getListReponse.then().assertThat()
.statusCode(OK.getStatusCode());
@@ -146,22 +119,19 @@ public void testSavedSearches() {
List