-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not allow zenodo pubs without publication date by default; provide…
… an override; associated with #303
- Loading branch information
Jorrit Poelen
committed
Sep 5, 2024
1 parent
39ff2f2
commit abc049a
Showing
6 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
56 changes: 56 additions & 0 deletions
56
...on-zenodo/src/test/java/bio/guoda/preston/zenodo/ZenodoMetadataFileStreamHandlerTest.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,56 @@ | ||
package bio.guoda.preston.zenodo; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class ZenodoMetadataFileStreamHandlerTest { | ||
|
||
@Test | ||
public void allowedDefinedPubDate() throws IOException { | ||
JsonNode jsonNode = new ObjectMapper().readTree(getClass().getResourceAsStream("batlit-data/example-batlit.json")); | ||
|
||
ZenodoContext contextDefault = new ZenodoContext("bla"); | ||
assertTrue(ZenodoMetadataFileStreamHandler.hasAllowedPublicationDate(jsonNode, contextDefault)); | ||
} | ||
|
||
@Test | ||
public void allowedEmptyPubDate() throws IOException { | ||
JsonNode jsonNode = new ObjectMapper().readTree(getClass().getResourceAsStream("batlit-data/example-batlit-no-pubdate.json")); | ||
|
||
ZenodoContext contextDefault = new ZenodoContext("bla"); | ||
contextDefault.setAllowEmptyPublicationDate(true); | ||
assertTrue(ZenodoMetadataFileStreamHandler.hasAllowedPublicationDate(jsonNode, contextDefault)); | ||
} | ||
|
||
@Test | ||
public void nonEmptyPubDateAllowed() throws IOException { | ||
JsonNode jsonNode = new ObjectMapper().readTree(getClass().getResourceAsStream("batlit-data/example-batlit.json")); | ||
|
||
ZenodoContext contextDefault = new ZenodoContext("bla"); | ||
contextDefault.setAllowEmptyPublicationDate(false); | ||
assertTrue(ZenodoMetadataFileStreamHandler.hasAllowedPublicationDate(jsonNode, contextDefault)); | ||
} | ||
|
||
@Test | ||
public void emptyPubDateNotAllowed() throws IOException { | ||
JsonNode jsonNode = new ObjectMapper().readTree(getClass().getResourceAsStream("batlit-data/example-batlit-no-pubdate.json")); | ||
|
||
ZenodoContext contextDefault = new ZenodoContext("bla"); | ||
assertFalse(ZenodoMetadataFileStreamHandler.hasAllowedPublicationDate(jsonNode, contextDefault)); | ||
} | ||
|
||
@Test | ||
public void emptyPubDateNotAllowed2() throws IOException { | ||
JsonNode jsonNode = new ObjectMapper().readTree(getClass().getResourceAsStream("batlit-data/example-batlit-no-pubdate.json")); | ||
|
||
ZenodoContext contextDefault = new ZenodoContext("bla"); | ||
contextDefault.setAllowEmptyPublicationDate(false); | ||
assertFalse(ZenodoMetadataFileStreamHandler.hasAllowedPublicationDate(jsonNode, contextDefault)); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...do/src/test/resources/bio/guoda/preston/zenodo/batlit-data/example-batlit-no-pubdate.json
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 @@ | ||
{"metadata":{"filename":"Thomas - 1912 - XXII.— A new Vespertilionine bat from Angolai.pdf","related_identifiers":[{"relation":"isAlternateIdentifier","identifier":"hash://md5/4c64e5b3477ea92404d0c915eaf06da3"},{"relation":"isAlternateIdentifier","identifier":"urn:lsid:zotero.org:groups:5435545:items:BF9WCVE5"},{"relation":"hasVersion","identifier":"hash://md5/4c64e5b3477ea92404d0c915eaf06da3"},{"relation":"hasVersion","identifier":"hash://sha256/691316c043fb8e6d686b034dd604cfd5e78e60205d4b2c0f404ce0cb81af9764"},{"relation":"isDerivedFrom","identifier":"zotero://select/groups/5435545/items/BF9WCVE5"},{"relation":"isDerivedFrom","identifier":"https://zotero.org/groups/5435545/items/BF9WCVE5"},{"relation":"isDerivedFrom","identifier":"https://linker.bio/cut:hash://md5/bd79ea31e23eae8897a9291bf4d7f24a!/b164740-167173"},{"relation":"isPartOf","identifier":"hash://md5/26f7ce5dd404e33c6570edd4ba250d20"},{"relation":"isAlternateIdentifier","identifier":"10.1080/00222931208693218"},{"relation":"isCompiledBy","identifier":"10.5281/zenodo.1410543","resource_type":"software"}],"communities":[{"identifier":"batlit"},{"identifier":"biosyslit"}],"http://www.w3.org/ns/prov#wasDerivedFrom":"https://linker.bio/cut:hash://md5/bd79ea31e23eae8897a9291bf4d7f24a!/b164740-167173","upload_type":"publication","http://www.w3.org/1999/02/22-rdf-syntax-ns#type":"application/json","referenceId":"https://api.zotero.org/groups/5435545/items/BF9WCVE5","creators":[{"name":"Thomas, Oldfield"}],"publication_type":"article","title":"A new Vespertilionine bat from Angola","journal_title":"Annals and Magazine of Natural History","journal_volume":"10","journal_issue":"56","journal_pages":"204-206","keywords":["Biodiversity","Mammalia","Chiroptera","Chordata","Animalia","bats","bat"],"custom":{"dwc:kingdom":["Animalia"],"dwc:phylum":["Chordata"],"dwc:class":["Mammalia"],"dwc:order":["Chiroptera"]},"description":"(Uploaded by Plazi for the Bat Literature Project) No abstract provided."}} |