[master] refactoring

This commit is contained in:
Miriam Baglioni 2023-06-21 11:15:53 +02:00
parent d9506035e4
commit e4b27182d0
4 changed files with 16 additions and 15 deletions

View File

@ -135,17 +135,17 @@ public class ZenodoAPIClient implements Serializable {
*/ */
public int uploadIS(InputStream is, String file_name, long len) throws IOException { public int uploadIS(InputStream is, String file_name, long len) throws IOException {
OkHttpClient httpClient = new OkHttpClient.Builder() OkHttpClient httpClient = new OkHttpClient.Builder()
.writeTimeout(600, TimeUnit.SECONDS) .writeTimeout(600, TimeUnit.SECONDS)
.readTimeout(600, TimeUnit.SECONDS) .readTimeout(600, TimeUnit.SECONDS)
.connectTimeout(600, TimeUnit.SECONDS) .connectTimeout(600, TimeUnit.SECONDS)
.build(); .build();
Request request = new Request.Builder() Request request = new Request.Builder()
.url(bucket + "/" + file_name) .url(bucket + "/" + file_name)
.addHeader(HttpHeaders.CONTENT_TYPE, "application/zip") // add request headers .addHeader(HttpHeaders.CONTENT_TYPE, "application/zip") // add request headers
.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + access_token) .addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + access_token)
.put(InputStreamRequestBody.create(MEDIA_TYPE_ZIP, is, len)) .put(InputStreamRequestBody.create(MEDIA_TYPE_ZIP, is, len))
.build(); .build();
try (Response response = httpClient.newCall(request).execute()) { try (Response response = httpClient.newCall(request).execute()) {
if (!response.isSuccessful()) if (!response.isSuccessful())

View File

@ -62,7 +62,7 @@ class ZenodoAPIClientTest {
Assertions.assertEquals(200, client.sendMretadata(metadata)); Assertions.assertEquals(200, client.sendMretadata(metadata));
// Assertions.assertEquals(202, client.publish()); // Assertions.assertEquals(202, client.publish());
} }
@ -109,7 +109,7 @@ class ZenodoAPIClientTest {
@Test @Test
void depositBigFile() throws MissingConceptDoiException, IOException { void depositBigFile() throws MissingConceptDoiException, IOException {
ZenodoAPIClient client = new ZenodoAPIClient(URL_STRING, ZenodoAPIClient client = new ZenodoAPIClient(URL_STRING,
ACCESS_TOKEN); ACCESS_TOKEN);
Assertions.assertEquals(201, client.newDeposition()); Assertions.assertEquals(201, client.newDeposition());
@ -122,7 +122,7 @@ 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());
} }
} }

View File

@ -1010,7 +1010,7 @@ class MappersTest {
@Test @Test
void testD4Science() throws IOException { void testD4Science() throws IOException {
final String xml = IOUtils final String xml = IOUtils
.toString(Objects.requireNonNull(getClass().getResourceAsStream("d4science.xml"))); .toString(Objects.requireNonNull(getClass().getResourceAsStream("d4science.xml")));
final List<Oaf> actual = new OdfToOafMapper(vocs, false, true).processMdRecord(xml); final List<Oaf> actual = new OdfToOafMapper(vocs, false, true).processMdRecord(xml);
assertNotNull(actual); assertNotNull(actual);
assertFalse(actual.isEmpty()); assertFalse(actual.isEmpty());
@ -1023,7 +1023,6 @@ class MappersTest {
} }
private void assertValidId(final String id) { private void assertValidId(final String id) {
// System.out.println(id); // System.out.println(id);

View File

@ -136,9 +136,11 @@ public class IndexRecordTransformerTest {
@Test @Test
public void testForEdithDemoCovid() throws IOException, TransformerException { public void testForEdithDemoCovid() throws IOException, TransformerException {
final String record = IOUtils.toString(getClass().getResourceAsStream("edith-demo/10.3390-pr9111967-covid.xml")); final String record = IOUtils
.toString(getClass().getResourceAsStream("edith-demo/10.3390-pr9111967-covid.xml"));
testRecordTransformation(record); testRecordTransformation(record);
} }
@Test @Test
public void testForEdithDemoEthics() throws IOException, TransformerException { public void testForEdithDemoEthics() throws IOException, TransformerException {
final String record = IOUtils.toString(getClass().getResourceAsStream("edith-demo/10.2196-33081-ethics.xml")); final String record = IOUtils.toString(getClass().getResourceAsStream("edith-demo/10.2196-33081-ethics.xml"));