Skip to content

Commit

Permalink
API test finished. #3437
Browse files Browse the repository at this point in the history
  • Loading branch information
landreev committed Jan 9, 2024
1 parent c6ec7fa commit 7c92067
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class OAIRecordServiceBean implements java.io.Serializable {
* marked as deleted without any further checks. Otherwise
* we'll want to double-check if the dataset still exists
* as published. This is to prevent marking existing datasets
* as deleted during a full reindex and such.
* as deleted during a full reindex etc.
* @param setUpdateLogger dedicated Logger
*/
public void updateOaiRecords(String setName, List<Long> datasetIds, Date updateTime, boolean doExport, boolean confirmed, Logger setUpdateLogger) {
Expand Down
42 changes: 40 additions & 2 deletions src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ public void testSingleRecordOaiSet() throws InterruptedException {
// Now, let's clear this dataset from Solr:
Response solrClearResponse = UtilIT.indexClearDataset(singleSetDatasetDatabaseId);
assertEquals(200, solrClearResponse.getStatusCode());
solrClearResponse.prettyPrint();

// Now, let's re-export the set. The search query that defines the set
// will no longer find it (todo: confirm this first?). However, since
Expand All @@ -570,7 +571,7 @@ public void testSingleRecordOaiSet() throws InterruptedException {

exportSetResponse = UtilIT.exportOaiSet(setName);
assertEquals(200, exportSetResponse.getStatusCode());
Thread.sleep(10000L); // wait for just a second, to be safe
Thread.sleep(1000L); // wait for just a second, to be safe

// OAI Test 5. Check ListIdentifiers again:

Expand All @@ -596,6 +597,43 @@ public void testSingleRecordOaiSet() throws InterruptedException {
// TODO: (?) we could also destroy the dataset for real now, and make
// sure the "deleted" attribute has been added to the OAI record.

// While we are at it, let's now destroy this dataset for real, and
// make sure the "deleted" attribute is actually added once the set
// is re-exported:

Response destroyDatasetResponse = UtilIT.destroyDataset(singleSetDatasetPersistentId, adminUserAPIKey);
assertEquals(200, destroyDatasetResponse.getStatusCode());
destroyDatasetResponse.prettyPrint();

// Confirm that it no longer exists:
Response datasetNotFoundResponse = UtilIT.nativeGet(singleSetDatasetDatabaseId, adminUserAPIKey);
assertEquals(404, datasetNotFoundResponse.getStatusCode());

// Repeat the whole production with re-exporting set and checking
// ListIdentifiers:

exportSetResponse = UtilIT.exportOaiSet(setName);
assertEquals(200, exportSetResponse.getStatusCode());
Thread.sleep(1000L); // wait for just a second, to be safe
System.out.println("re-exported the dataset again, with the control dataset destroyed");

// OAI Test 6. Check ListIdentifiers again:

listIdentifiersResponse = UtilIT.getOaiListIdentifiers(setName, "oai_dc");
assertEquals(OK.getStatusCode(), listIdentifiersResponse.getStatusCode());

// Validate the service section of the OAI response:
responseXmlPath = validateOaiVerbResponse(listIdentifiersResponse, "ListIdentifiers");

// ... and confirm that the record for our dataset is still listed...
ret = responseXmlPath.getList("OAI-PMH.ListIdentifiers.header");
assertEquals(1, ret.size());
assertEquals(singleSetDatasetPersistentId, responseXmlPath
.getString("OAI-PMH.ListIdentifiers.header.identifier"));

// ... BUT, it should be marked as "deleted" now:
assertEquals(responseXmlPath.getString("OAI-PMH.ListIdentifiers.header.@status"), "deleted");

}

// This test will attempt to create a set with multiple records (enough
Expand Down Expand Up @@ -910,7 +948,7 @@ public void testMultiRecordOaiSet() throws InterruptedException {
// TODO:
// What else can we test?
// Some ideas:
// - Test handling of deleted dataset records
// - Test handling of deleted dataset records - DONE!
// - Test "from" and "until" time parameters
// - Validate full verb response records against XML schema
// (for each supported metadata format, possibly?)
Expand Down

0 comments on commit 7c92067

Please sign in to comment.