Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4664 OpenAIRE compliance: New tests #4

Open
wants to merge 1 commit into
base: openaire
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package edu.harvard.iq.dataverse.export;

import com.jayway.restassured.path.xml.XmlPath;
import com.jayway.restassured.path.xml.element.Node;
import com.jayway.restassured.path.xml.element.NodeChildren;
import edu.harvard.iq.dataverse.DatasetVersion;
import edu.harvard.iq.dataverse.util.xml.XmlPrinter;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -67,6 +69,26 @@ public void testExportDataset() throws Exception {
assertEquals("Spruce Goose", xmlpath.getString("resource.titles.title"));
assertEquals("Spruce, Sabrina", xmlpath.getString("resource.creators.creator"));
assertEquals("1.0", xmlpath.getString("resource.version"));

datasetVersionJson = new File("src/test/java/edu/harvard/iq/dataverse/export/backToFuture.json");
datasetVersionAsJson = new String(Files.readAllBytes(Paths.get(datasetVersionJson.getAbsolutePath())));
jsonReader = Json.createReader(new StringReader(datasetVersionAsJson));
jsonObject = jsonReader.readObject();
nullVersion = null;
byteArrayOutputStream = new ByteArrayOutputStream();
openAireExporter.exportDataset(nullVersion, jsonObject, byteArrayOutputStream);
xmlOnOneLine = new String(byteArrayOutputStream.toByteArray());
xmlAsString = XmlPrinter.prettyPrintXml(xmlOnOneLine);
System.out.println("XML: " + xmlAsString);
xmlpath = XmlPath.from(xmlAsString);
assertEquals("Back to the Future", xmlpath.getList("resource.titles.title").get(0));
assertEquals("Robert Zemeckis", xmlpath.getString("resource.creators.creator.creatorName"));
assertEquals("0001-0002-0003-0004", xmlpath.get("resource.creators.creator.nameIdentifier.findAll {it.@nameIdentifierScheme == 'ORCID'}"));
assertEquals("1985-01", xmlpath.get("resource.dates.date.findAll { it.@dateType == 'Created'}"));
assertEquals("1985-01-01", xmlpath.get("resource.dates.date.findAll { it.@dateType == 'Issued'}"));
assertEquals("1985-02/1985-03", xmlpath.get("resource.dates.date.findAll { it.@dateType == 'Collected'}"));
assertEquals("United States; California; Hill Valley; fantasy cityHill Valley City32.64542843 116.36588226", xmlpath.getString("resources.geoLocations.geoLocation.geoLocationPlace"));

}

/**
Expand Down
Loading