-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
src/test/java/edu/harvard/iq/dataverse/api/DataCiteIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package edu.harvard.iq.dataverse.api; | ||
|
||
import com.jayway.restassured.response.Response; | ||
import static junit.framework.Assert.assertEquals; | ||
import org.junit.Test; | ||
|
||
/** | ||
* These tests will only work if you are using "DataCite" rather than "EZID" for | ||
* your :DoiProvider and have done all the other related setup to switch from | ||
* EZID, including setting JVM options. Look for DataCite in the dev guide for | ||
* more tips. | ||
*/ | ||
public class DataCiteIT { | ||
|
||
@Test | ||
public void testCreateAndPublishDataset() { | ||
|
||
Response createUser = UtilIT.createRandomUser(); | ||
createUser.prettyPrint(); | ||
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); | ||
createDataverseResponse.prettyPrint(); | ||
String dataverseAlias = UtilIT.getAliasFromResponse(createDataverseResponse); | ||
|
||
String title = "myTitle"; | ||
String description = "myDescription"; | ||
Response createDataset = UtilIT.createDatasetViaSwordApi(dataverseAlias, title, description, apiToken); | ||
createDataset.prettyPrint(); | ||
String datasetPersistentId = UtilIT.getDatasetPersistentIdFromResponse(createDataset); | ||
|
||
Response publishDataverse = UtilIT.publishDataverseViaSword(dataverseAlias, apiToken); | ||
assertEquals(200, publishDataverse.getStatusCode()); | ||
|
||
Response publishDataset = UtilIT.publishDatasetViaNativeApi(datasetPersistentId, "major", apiToken); | ||
publishDataset.prettyPrint(); | ||
assertEquals(200, publishDataset.getStatusCode()); | ||
|
||
} | ||
|
||
@Test | ||
public void testCreateAndPublishDatasetHtmlInDescription() { | ||
|
||
Response createUser = UtilIT.createRandomUser(); | ||
createUser.prettyPrint(); | ||
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); | ||
createDataverseResponse.prettyPrint(); | ||
String dataverseAlias = UtilIT.getAliasFromResponse(createDataverseResponse); | ||
|
||
String title = "myTitle"; | ||
// TODO: exercise https://github.com/IQSS/dataverse/issues/3845 by putting HTML in dataset description | ||
String description = "BEGIN<br></br>END"; | ||
if (true) { | ||
return; | ||
} | ||
Response createDataset = UtilIT.createDatasetViaSwordApi(dataverseAlias, title, description, apiToken); | ||
createDataset.prettyPrint(); | ||
String datasetPersistentId = UtilIT.getDatasetPersistentIdFromResponse(createDataset); | ||
|
||
Response publishDataverse = UtilIT.publishDataverseViaSword(dataverseAlias, apiToken); | ||
assertEquals(200, publishDataverse.getStatusCode()); | ||
|
||
Response publishDataset = UtilIT.publishDatasetViaNativeApi(datasetPersistentId, "major", apiToken); | ||
publishDataset.prettyPrint(); | ||
assertEquals(200, publishDataset.getStatusCode()); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters