[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 {
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())

View File

@ -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());
}
}

View File

@ -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<Oaf> 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);

View File

@ -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"));