Skip to content

Commit 5230722

Browse files
verastevenwinship
andauthored
fix: fix bug in notifications API related to SUBMITTEDDS notifications (#12152)
* fix: fix bug in notifications API related to SUBMITTEDDS notifications * test: extend InReviewWorkflowIT * Update InReviewWorkflowIT.java fixing conflict with merge * test: adapt InAppNotificationsJsonPrinterTest#testAddFieldsByType_submittedDs --------- Co-authored-by: Steven Winship <39765413+stevenwinship@users.noreply.github.com>
1 parent 24dedde commit 5230722

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

src/main/java/edu/harvard/iq/dataverse/util/json/InAppNotificationsJsonPrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private void addGuidesFields(final NullSafeJsonBuilder notificationJson, String
241241
}
242242

243243
private void addSubmittedDatasetFields(final NullSafeJsonBuilder notificationJson, final UserNotification userNotification, final AuthenticatedUser requestor) {
244-
addDatasetFields(notificationJson, userNotification);
244+
addDatasetVersionFields(notificationJson, userNotification);
245245
addRequestorFields(notificationJson, requestor);
246246
}
247247

src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,40 @@ public void testCuratorSendsCommentsToAuthor() {
437437
// .body("data[3].reasonsForReturn", equalTo(null))
438438
.statusCode(OK.getStatusCode());
439439

440-
// Confirm that when getting the dataset, the "InReview" lock is no longer listed
441-
JsonArray emptyArray = Json.createArrayBuilder().build();
442-
getDatasetJson = UtilIT.nativeGet(datasetId, authorApiToken);
443-
getDatasetJson.prettyPrint();
444-
getDatasetJson.then().assertThat()
445-
.body("data.locks", equalTo(emptyArray))
446-
.statusCode(200);
440+
// The author realizes she wants to add another file and creates a new draft version.
441+
Response authorAddsNewFileCreatingNewDraft = UtilIT.uploadFileViaNative(datasetId.toString(), pathToFile1, authorApiToken);
442+
authorAddsNewFileCreatingNewDraft.prettyPrint();
443+
authorAddsNewFileCreatingNewDraft.then().assertThat()
444+
.statusCode(OK.getStatusCode());
445+
446+
// The author re-submits.
447+
Response submit4 = UtilIT.submitDatasetForReview(datasetPersistentId, authorApiToken);
448+
submit4.prettyPrint();
449+
submit4.then().assertThat()
450+
.body("data.inReview", equalTo(true))
451+
.statusCode(OK.getStatusCode());
452+
453+
// The curator checks notifications and sees that the dataset has been re-submitted after it was published.
454+
Response curatorChecksForNotificationsPostPublication = UtilIT.getNotifications(curatorApiToken);
455+
curatorChecksForNotificationsPostPublication.prettyPrint();
456+
curatorChecksForNotificationsPostPublication.then().assertThat()
457+
.body("data[0].type", equalTo(SUBMITTEDDS.toString()))
458+
.body("data[1].type", equalTo(PUBLISHEDDS.toString()))
459+
.statusCode(OK.getStatusCode());
460+
461+
// The curator checks again, this time in app notification format.
462+
Response curatorChecksForNotificationsPostPublicationInAppFormat = UtilIT.getNotifications(curatorApiToken, true, null, null, null);
463+
curatorChecksForNotificationsPostPublicationInAppFormat.prettyPrint();
464+
curatorChecksForNotificationsPostPublicationInAppFormat.then().assertThat()
465+
.body("data[0].type", equalTo(SUBMITTEDDS.toString()))
466+
.body("data[0].objectDeleted", equalTo(null))
467+
.body("data[0].datasetPersistentIdentifier", equalTo(datasetPersistentId))
468+
.body("data[0].ownerAlias", equalTo(dataverseAlias))
469+
.body("data[1].type", equalTo(PUBLISHEDDS.toString()))
470+
.body("data[1].objectDeleted", equalTo(null))
471+
.body("data[1].datasetPersistentIdentifier", equalTo(datasetPersistentId))
472+
.body("data[1].ownerAlias", equalTo(dataverseAlias))
473+
.statusCode(OK.getStatusCode());
447474

448475
// These println's are here in case you want to log into the GUI to see what notifications look like.
449476
System.out.println("Curator username/password: " + curatorUsername);

src/test/java/edu/harvard/iq/dataverse/util/json/InAppNotificationsJsonPrinterTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,16 @@ public void testAddFieldsByType_submittedDs() {
402402
userNotification.setObjectId(1L);
403403
userNotification.setRequestor(requestor);
404404

405+
DatasetVersion datasetVersion = mock(DatasetVersion.class);
405406
Dataset dataset = mock(Dataset.class);
406407
Dataverse owner = mock(Dataverse.class);
407408

409+
when(datasetVersion.getDataset()).thenReturn(dataset);
410+
408411
when(dataset.getGlobalId()).thenReturn(testGlobalId);
409412
when(dataset.getDisplayName()).thenReturn("Submitted Dataset");
410413
when(dataset.getOwner()).thenReturn(owner);
411-
when(datasetService.find(1L)).thenReturn(dataset);
414+
when(datasetVersionService.find(1L)).thenReturn(datasetVersion);
412415

413416
when(owner.getAlias()).thenReturn("reviewDv");
414417
when(owner.getDisplayName()).thenReturn("Review Dataverse");

0 commit comments

Comments
 (0)