From e4b27182d0c55ef2dd566e7d0f12da2b6e32a6b1 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Wed, 21 Jun 2023 11:15:53 +0200 Subject: [PATCH] [master] refactoring --- .../dhp/common/api/ZenodoAPIClient.java | 18 +++++++++--------- .../dhp/common/api/ZenodoAPIClientTest.java | 6 +++--- .../dnetlib/dhp/oa/graph/raw/MappersTest.java | 3 +-- .../provision/IndexRecordTransformerTest.java | 4 +++- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java b/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java index a69624e3b..0164bd249 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java @@ -135,17 +135,17 @@ public class ZenodoAPIClient implements Serializable { */ public int uploadIS(InputStream is, String file_name, long len) throws IOException { OkHttpClient httpClient = new OkHttpClient.Builder() - .writeTimeout(600, TimeUnit.SECONDS) - .readTimeout(600, TimeUnit.SECONDS) - .connectTimeout(600, TimeUnit.SECONDS) - .build(); + .writeTimeout(600, TimeUnit.SECONDS) + .readTimeout(600, TimeUnit.SECONDS) + .connectTimeout(600, TimeUnit.SECONDS) + .build(); Request request = new Request.Builder() - .url(bucket + "/" + file_name) - .addHeader(HttpHeaders.CONTENT_TYPE, "application/zip") // add request headers - .addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + access_token) - .put(InputStreamRequestBody.create(MEDIA_TYPE_ZIP, is, len)) - .build(); + .url(bucket + "/" + file_name) + .addHeader(HttpHeaders.CONTENT_TYPE, "application/zip") // add request headers + .addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + access_token) + .put(InputStreamRequestBody.create(MEDIA_TYPE_ZIP, is, len)) + .build(); try (Response response = httpClient.newCall(request).execute()) { if (!response.isSuccessful()) diff --git a/dhp-common/src/test/java/eu/dnetlib/dhp/common/api/ZenodoAPIClientTest.java b/dhp-common/src/test/java/eu/dnetlib/dhp/common/api/ZenodoAPIClientTest.java index 87b68617b..15ca81d17 100644 --- a/dhp-common/src/test/java/eu/dnetlib/dhp/common/api/ZenodoAPIClientTest.java +++ b/dhp-common/src/test/java/eu/dnetlib/dhp/common/api/ZenodoAPIClientTest.java @@ -62,7 +62,7 @@ class ZenodoAPIClientTest { Assertions.assertEquals(200, client.sendMretadata(metadata)); - // Assertions.assertEquals(202, client.publish()); + // Assertions.assertEquals(202, client.publish()); } @@ -109,7 +109,7 @@ class ZenodoAPIClientTest { @Test void depositBigFile() throws MissingConceptDoiException, IOException { ZenodoAPIClient client = new ZenodoAPIClient(URL_STRING, - ACCESS_TOKEN); + ACCESS_TOKEN); Assertions.assertEquals(201, client.newDeposition()); @@ -122,7 +122,7 @@ class ZenodoAPIClientTest { Assertions.assertEquals(200, client.uploadIS(is, "newVersion_deposition", file.length())); - //Assertions.assertEquals(202, client.publish()); + // Assertions.assertEquals(202, client.publish()); } } diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java index bfd6d461d..55b49ee4f 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java @@ -1010,7 +1010,7 @@ class MappersTest { @Test void testD4Science() throws IOException { final String xml = IOUtils - .toString(Objects.requireNonNull(getClass().getResourceAsStream("d4science.xml"))); + .toString(Objects.requireNonNull(getClass().getResourceAsStream("d4science.xml"))); final List actual = new OdfToOafMapper(vocs, false, true).processMdRecord(xml); assertNotNull(actual); assertFalse(actual.isEmpty()); @@ -1023,7 +1023,6 @@ class MappersTest { } - private void assertValidId(final String id) { // System.out.println(id); diff --git a/dhp-workflows/dhp-graph-provision/src/test/java/eu/dnetlib/dhp/oa/provision/IndexRecordTransformerTest.java b/dhp-workflows/dhp-graph-provision/src/test/java/eu/dnetlib/dhp/oa/provision/IndexRecordTransformerTest.java index 74f203cbf..b5a5b5f0d 100644 --- a/dhp-workflows/dhp-graph-provision/src/test/java/eu/dnetlib/dhp/oa/provision/IndexRecordTransformerTest.java +++ b/dhp-workflows/dhp-graph-provision/src/test/java/eu/dnetlib/dhp/oa/provision/IndexRecordTransformerTest.java @@ -136,9 +136,11 @@ public class IndexRecordTransformerTest { @Test 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); } + @Test public void testForEdithDemoEthics() throws IOException, TransformerException { final String record = IOUtils.toString(getClass().getResourceAsStream("edith-demo/10.2196-33081-ethics.xml"));