2020-04-27 14:52:31 +02:00
|
|
|
|
2019-10-24 11:36:59 +02:00
|
|
|
package eu.dnetlib.dhp.collector.worker;
|
2019-04-03 16:05:16 +02:00
|
|
|
|
2020-04-18 12:42:58 +02:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
|
|
2021-01-28 09:51:17 +01:00
|
|
|
import java.nio.file.Path;
|
2020-04-28 11:23:29 +02:00
|
|
|
|
2020-06-09 19:52:53 +02:00
|
|
|
import org.junit.jupiter.api.Disabled;
|
2020-04-28 11:23:29 +02:00
|
|
|
import org.junit.jupiter.api.Test;
|
2021-01-28 09:51:17 +01:00
|
|
|
import org.junit.jupiter.api.io.TempDir;
|
2020-04-28 11:23:29 +02:00
|
|
|
|
2019-10-02 14:45:12 +02:00
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
2020-04-28 11:23:29 +02:00
|
|
|
|
2021-01-28 09:51:17 +01:00
|
|
|
import eu.dnetlib.dhp.collection.worker.CollectorWorker;
|
2019-10-24 11:36:59 +02:00
|
|
|
import eu.dnetlib.dhp.collection.worker.utils.CollectorPluginFactory;
|
2021-01-29 16:42:41 +01:00
|
|
|
import eu.dnetlib.dhp.collector.worker.model.ApiDescriptor;
|
2019-04-03 16:05:16 +02:00
|
|
|
|
2020-06-09 19:52:53 +02:00
|
|
|
@Disabled
|
2019-04-03 16:05:16 +02:00
|
|
|
public class DnetCollectorWorkerApplicationTests {
|
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Test
|
|
|
|
public void testFindPlugin() throws Exception {
|
|
|
|
final CollectorPluginFactory collectorPluginEnumerator = new CollectorPluginFactory();
|
|
|
|
assertNotNull(collectorPluginEnumerator.getPluginByProtocol("oai"));
|
|
|
|
assertNotNull(collectorPluginEnumerator.getPluginByProtocol("OAI"));
|
|
|
|
}
|
2019-10-02 14:45:12 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Test
|
|
|
|
public void testCollectionOAI() throws Exception {
|
|
|
|
final ApiDescriptor api = new ApiDescriptor();
|
|
|
|
api.setId("oai");
|
|
|
|
api.setProtocol("oai");
|
|
|
|
api.setBaseUrl("http://www.revista.vocesdelaeducacion.com.mx/index.php/index/oai");
|
|
|
|
api.getParams().put("format", "oai_dc");
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
assertNotNull(mapper.writeValueAsString(api));
|
|
|
|
}
|
2019-04-03 16:05:16 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Test
|
2021-01-28 09:51:17 +01:00
|
|
|
public void testFeeding(@TempDir Path testDir) throws Exception {
|
|
|
|
|
|
|
|
System.out.println(testDir.toString());
|
2021-02-03 12:33:41 +01:00
|
|
|
CollectorWorker worker = new CollectorWorker(getApi(),
|
2021-01-28 09:51:17 +01:00
|
|
|
"file://" + testDir.toString() + "/file.seq", testDir.toString() + "/file.seq");
|
2020-04-27 14:52:31 +02:00
|
|
|
worker.collect();
|
2021-01-28 09:51:17 +01:00
|
|
|
|
|
|
|
// TODO create ASSERT HERE
|
2020-04-27 14:52:31 +02:00
|
|
|
}
|
2019-04-03 16:05:16 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
private ApiDescriptor getApi() {
|
|
|
|
final ApiDescriptor api = new ApiDescriptor();
|
|
|
|
api.setId("oai");
|
|
|
|
api.setProtocol("oai");
|
|
|
|
api.setBaseUrl("http://www.revista.vocesdelaeducacion.com.mx/index.php/index/oai");
|
|
|
|
api.getParams().put("format", "oai_dc");
|
|
|
|
return api;
|
|
|
|
}
|
2019-04-03 16:05:16 +02:00
|
|
|
}
|