2018-10-02 10:37:54 +02:00
|
|
|
package eu.dnetlib.pace.config;
|
|
|
|
|
2019-12-13 11:30:02 +01:00
|
|
|
|
2018-10-02 10:37:54 +02:00
|
|
|
import eu.dnetlib.pace.AbstractPaceTest;
|
2019-12-05 14:14:25 +01:00
|
|
|
import eu.dnetlib.pace.model.MapDocument;
|
|
|
|
import eu.dnetlib.pace.util.MapDocumentUtil;
|
|
|
|
import org.apache.commons.io.IOUtils;
|
2018-10-02 10:37:54 +02:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2019-11-07 12:47:12 +01:00
|
|
|
import java.util.Map;
|
|
|
|
|
2018-10-26 14:55:59 +02:00
|
|
|
import static org.junit.Assert.assertEquals;
|
2018-10-02 10:37:54 +02:00
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
|
|
|
|
public class ConfigTest extends AbstractPaceTest {
|
|
|
|
|
|
|
|
@Test
|
2018-10-29 16:16:11 +01:00
|
|
|
public void dedupConfigSerializationTest() {
|
2019-11-07 12:47:12 +01:00
|
|
|
final DedupConfig cfgFromClasspath = DedupConfig.load(readFromClasspath("organization.current.conf"));
|
2018-10-02 10:37:54 +02:00
|
|
|
|
2018-10-29 16:16:11 +01:00
|
|
|
final String conf = cfgFromClasspath.toString();
|
|
|
|
|
|
|
|
final DedupConfig cfgFromSerialization = DedupConfig.load(conf);
|
|
|
|
|
|
|
|
assertEquals(cfgFromClasspath.toString(), cfgFromSerialization.toString());
|
|
|
|
|
2018-10-26 14:55:59 +02:00
|
|
|
assertNotNull(cfgFromClasspath);
|
2018-10-29 16:16:11 +01:00
|
|
|
assertNotNull(cfgFromSerialization);
|
2018-10-26 14:55:59 +02:00
|
|
|
|
2018-10-02 10:37:54 +02:00
|
|
|
}
|
|
|
|
|
2018-10-29 11:13:55 +01:00
|
|
|
@Test
|
|
|
|
public void dedupConfigTest() {
|
|
|
|
|
2019-11-07 12:47:12 +01:00
|
|
|
DedupConfig load = DedupConfig.load(readFromClasspath("organization.current.conf"));
|
2018-10-29 11:13:55 +01:00
|
|
|
|
|
|
|
System.out.println(load.toString());
|
|
|
|
}
|
|
|
|
|
2019-10-08 15:13:45 +02:00
|
|
|
@Test
|
2019-11-07 12:47:12 +01:00
|
|
|
public void initTranslationMapTest() {
|
|
|
|
|
|
|
|
DedupConfig load = DedupConfig.load(readFromClasspath("organization.current.conf"));
|
|
|
|
|
|
|
|
Map<String, String> translationMap = load.translationMap();
|
|
|
|
|
|
|
|
System.out.println("translationMap = " + translationMap.size());
|
2019-10-08 15:13:45 +02:00
|
|
|
|
2019-11-07 12:47:12 +01:00
|
|
|
for (String key: translationMap.keySet()) {
|
|
|
|
if (translationMap.get(key).equals("key::1"))
|
|
|
|
System.out.println("key = " + key);
|
|
|
|
}
|
2019-10-08 15:13:45 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-10-23 16:31:45 +02:00
|
|
|
@Test
|
|
|
|
public void emptyTranslationMapTest() {
|
|
|
|
|
2019-11-07 12:47:12 +01:00
|
|
|
DedupConfig load = DedupConfig.load(readFromClasspath("organization.no_synonyms.conf"));
|
2019-10-23 16:31:45 +02:00
|
|
|
|
|
|
|
assertEquals(0, load.getPace().translationMap().keySet().size());
|
|
|
|
}
|
|
|
|
|
2019-12-05 14:14:25 +01:00
|
|
|
|
2019-12-13 11:30:02 +01:00
|
|
|
|
2019-12-05 14:14:25 +01:00
|
|
|
@Test
|
|
|
|
public void testAsMapDocumentJPath() throws Exception {
|
|
|
|
|
|
|
|
DedupConfig load = DedupConfig.load(readFromClasspath("result.pace.conf_jpath.json"));
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(load.getWf().getIdPath());
|
|
|
|
|
|
|
|
final String result =IOUtils.toString(this.getClass().getResourceAsStream("result.json"));
|
|
|
|
|
|
|
|
System.out.println(result);
|
|
|
|
final MapDocument mapDocument = MapDocumentUtil.asMapDocumentWithJPath(load, result);
|
|
|
|
|
|
|
|
System.out.println(mapDocument.getFieldMap());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-02 10:37:54 +02:00
|
|
|
}
|