code formatting

This commit is contained in:
Claudio Atzori 2021-05-05 11:23:57 +02:00
parent b1785ba77c
commit 2e1eb96f9a
1 changed files with 20 additions and 17 deletions

View File

@ -1,10 +1,10 @@
package eu.dnetlib.dhp.oa.graph.raw; package eu.dnetlib.dhp.oa.graph.raw;
import com.mongodb.client.MongoDatabase; import java.io.IOException;
import eu.dnetlib.dhp.common.MdstoreClient; import java.nio.file.Files;
import io.fares.junit.mongodb.MongoExtension; import java.nio.file.Path;
import io.fares.junit.mongodb.MongoForAllExtension;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bson.Document; import org.bson.Document;
@ -16,9 +16,11 @@ import org.junit.jupiter.api.io.TempDir;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; import com.mongodb.client.MongoDatabase;
import java.nio.file.Files;
import java.nio.file.Path; import eu.dnetlib.dhp.common.MdstoreClient;
import io.fares.junit.mongodb.MongoExtension;
import io.fares.junit.mongodb.MongoForAllExtension;
public class MigrateMongoMdstoresApplicationTest { public class MigrateMongoMdstoresApplicationTest {
@ -38,10 +40,9 @@ public class MigrateMongoMdstoresApplicationTest {
db.getCollection("metadataManager").insertOne(Document.parse(read("mdstore_metadataManager.json"))); db.getCollection("metadataManager").insertOne(Document.parse(read("mdstore_metadataManager.json")));
} }
@Test @Test
public void test_MdstoreClient() throws IOException { public void test_MdstoreClient() throws IOException {
try(MdstoreClient client = new MdstoreClient(mongo.getMongoClient(), MongoExtension.UNIT_TEST_DB)) { try (MdstoreClient client = new MdstoreClient(mongo.getMongoClient(), MongoExtension.UNIT_TEST_DB)) {
for (String xml : client.listRecords(COLL_NAME)) { for (String xml : client.listRecords(COLL_NAME)) {
Assertions.assertTrue(StringUtils.isNotBlank(xml)); Assertions.assertTrue(StringUtils.isNotBlank(xml));
} }
@ -55,17 +56,19 @@ public class MigrateMongoMdstoresApplicationTest {
Path outputPath = tmpPath.resolve(seqFile); Path outputPath = tmpPath.resolve(seqFile);
try (MigrateMongoMdstoresApplication app = new MigrateMongoMdstoresApplication( try (MigrateMongoMdstoresApplication app = new MigrateMongoMdstoresApplication(
outputPath.toString(), outputPath.toString(),
mongo.getMongoClient(), mongo.getMongoClient(),
MongoExtension.UNIT_TEST_DB)) { MongoExtension.UNIT_TEST_DB)) {
app.execute("oai_dc", "store", "native"); app.execute("oai_dc", "store", "native");
} }
Assertions.assertTrue( Assertions
Files.list(tmpPath) .assertTrue(
.filter(f -> seqFile.contains(f.getFileName().toString())) Files
.findFirst() .list(tmpPath)
.isPresent()); .filter(f -> seqFile.contains(f.getFileName().toString()))
.findFirst()
.isPresent());
} }
private static String read(String filename) throws IOException { private static String read(String filename) throws IOException {