Skip to content

Commit

Permalink
fix(api-test): make DatasetsIT not fail tests when no stored procedure
Browse files Browse the repository at this point in the history
…IQSS#8251

When no stored procedure has been set up in the instance under test,
test running after
DatasetsIT.testStoredProcGeneratedAsIdentifierGenerationStyle() failed,
as the database setting was never reverted.

Making use of the new @DBSetting extension helps with that.
  • Loading branch information
poikilotherm committed Nov 22, 2021
1 parent ed4e08f commit 1a264eb
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.jayway.restassured.response.Response;
import java.util.logging.Logger;

import edu.harvard.iq.dataverse.api.helpers.DBSetting;
import edu.harvard.iq.dataverse.api.helpers.Tags;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -760,6 +761,7 @@ public void testExcludeEmail() {
}

@Test
@DBSetting(name = SettingsServiceBean.Key.IdentifierGenerationStyle, value = "storedProcGenerated")
public void testStoredProcGeneratedAsIdentifierGenerationStyle() {
// Please note that this test only works if the stored procedure
// named generateIdentifierFromStoredProcedure() has been created in the
Expand All @@ -782,10 +784,6 @@ public void testStoredProcGeneratedAsIdentifierGenerationStyle() {
createDataverseResponse.prettyPrint();
String dataverseAlias = UtilIT.getAliasFromResponse(createDataverseResponse);

Response setStoredProcGeneratedAsIdentifierGenerationStyle = UtilIT.setSetting(SettingsServiceBean.Key.IdentifierGenerationStyle, "storedProcGenerated");
setStoredProcGeneratedAsIdentifierGenerationStyle.then().assertThat()
.statusCode(OK.getStatusCode());

Response createDatasetResponse = UtilIT.createRandomDatasetViaNativeApi(dataverseAlias, apiToken);
createDatasetResponse.prettyPrint();
Integer datasetId = UtilIT.getDatasetIdFromResponse(createDatasetResponse);
Expand Down Expand Up @@ -816,11 +814,6 @@ public void testStoredProcGeneratedAsIdentifierGenerationStyle() {
Response deleteUserResponse = UtilIT.deleteUser(username);
deleteUserResponse.prettyPrint();
assertEquals(200, deleteUserResponse.getStatusCode());

Response remove = UtilIT.deleteSetting(SettingsServiceBean.Key.IdentifierGenerationStyle);
remove.then().assertThat()
.statusCode(200);

}

/**
Expand Down

0 comments on commit 1a264eb

Please sign in to comment.