forked from D-Net/dnet-hadoop
This commit is contained in:
parent
87856467e2
commit
a6df01d329
|
@ -1,26 +1,19 @@
|
||||||
package eu.dnetlib.dhp.common.api;
|
package eu.dnetlib.dhp.common.api;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
|
||||||
import org.apache.hadoop.fs.*;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ZenodoAPIClientTest {
|
public class ZenodoAPIClientTest {
|
||||||
|
|
||||||
private final String URL_STRING = "https://sandbox.zenodo.org/api/deposit/depositions";
|
private final String URL_STRING = "https://sandbox.zenodo.org/api/deposit/depositions";
|
||||||
private final String ACCESS_TOKEN = "5ImUj0VC1ICg4ifK5dc3AGzJhcfAB4osxrFlsr8WxHXxjaYgCE0hY8HZcDoe";
|
private final String ACCESS_TOKEN = "";
|
||||||
|
|
||||||
private final String CONCEPT_REC_ID = "657113";
|
private final String CONCEPT_REC_ID = "657113";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewDeposition() throws IOException {
|
public void testNewDeposition() throws IOException {
|
||||||
|
|
||||||
|
@ -34,8 +27,7 @@ public class ZenodoAPIClientTest {
|
||||||
|
|
||||||
InputStream is = new FileInputStream(file);
|
InputStream is = new FileInputStream(file);
|
||||||
|
|
||||||
Assertions.assertEquals(200,client.uploadIS(is, "first_deposition", file.length()));
|
Assertions.assertEquals(200, client.uploadIS(is, "first_deposition", file.length()));
|
||||||
|
|
||||||
|
|
||||||
String metadata = "{\"metadata\":{\"access_right\":\"open\",\"creators\":[{\"affiliation\":\"ISTI - CNR\",\"name\":\"Baglioni, Miriam\",\"orcid\":\"0000-0002-2273-9004\"}],\"description\":\"\\u003cp\\u003eThis is a test for the automatic upload of files in a new deposition\\u003c/p\\u003e \",\"title\":\"Test.\",\"upload_type\":\"other\",\"version\":\"1.0\"}}";
|
String metadata = "{\"metadata\":{\"access_right\":\"open\",\"creators\":[{\"affiliation\":\"ISTI - CNR\",\"name\":\"Baglioni, Miriam\",\"orcid\":\"0000-0002-2273-9004\"}],\"description\":\"\\u003cp\\u003eThis is a test for the automatic upload of files in a new deposition\\u003c/p\\u003e \",\"title\":\"Test.\",\"upload_type\":\"other\",\"version\":\"1.0\"}}";
|
||||||
|
|
||||||
|
@ -45,11 +37,9 @@ public class ZenodoAPIClientTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewVersionNewName() throws IOException, MissingConceptDoiException {
|
public void testNewVersionNewName() throws IOException, MissingConceptDoiException {
|
||||||
|
|
||||||
|
|
||||||
ZenodoAPIClient client = new ZenodoAPIClient(URL_STRING,
|
ZenodoAPIClient client = new ZenodoAPIClient(URL_STRING,
|
||||||
ACCESS_TOKEN);
|
ACCESS_TOKEN);
|
||||||
|
|
||||||
|
@ -63,7 +53,6 @@ public class ZenodoAPIClientTest {
|
||||||
|
|
||||||
Assertions.assertEquals(200, client.uploadIS(is, "newVersion_deposition", file.length()));
|
Assertions.assertEquals(200, client.uploadIS(is, "newVersion_deposition", file.length()));
|
||||||
|
|
||||||
|
|
||||||
Assertions.assertEquals(202, client.publish());
|
Assertions.assertEquals(202, client.publish());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,7 +60,6 @@ public class ZenodoAPIClientTest {
|
||||||
@Test
|
@Test
|
||||||
public void testNewVersionOldName() throws IOException, MissingConceptDoiException {
|
public void testNewVersionOldName() throws IOException, MissingConceptDoiException {
|
||||||
|
|
||||||
|
|
||||||
ZenodoAPIClient client = new ZenodoAPIClient(URL_STRING,
|
ZenodoAPIClient client = new ZenodoAPIClient(URL_STRING,
|
||||||
ACCESS_TOKEN);
|
ACCESS_TOKEN);
|
||||||
|
|
||||||
|
@ -85,7 +73,6 @@ public class ZenodoAPIClientTest {
|
||||||
|
|
||||||
Assertions.assertEquals(200, client.uploadIS(is, "newVersion_deposition", file.length()));
|
Assertions.assertEquals(200, client.uploadIS(is, "newVersion_deposition", file.length()));
|
||||||
|
|
||||||
|
|
||||||
Assertions.assertEquals(202, client.publish());
|
Assertions.assertEquals(202, client.publish());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue