1
|
package eu.dnetlib.data.mdstore.modular.mongodb;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.io.InputStream;
|
5
|
import java.util.ArrayList;
|
6
|
import java.util.List;
|
7
|
import java.util.Map;
|
8
|
|
9
|
import eu.dnetlib.data.mdstore.MDStoreServiceException;
|
10
|
import eu.dnetlib.data.mdstore.modular.MDFormatDescription;
|
11
|
import eu.dnetlib.data.mdstore.modular.mongodb.utils.IndexFieldRecordParser;
|
12
|
import eu.dnetlib.data.mdstore.modular.mongodb.utils.IndexFieldRecordParserException;
|
13
|
import org.apache.commons.io.IOUtils;
|
14
|
import org.junit.Test;
|
15
|
|
16
|
/**
|
17
|
* Created by sandro on 11/29/16.
|
18
|
*/
|
19
|
public class IndexFieldParserTest {
|
20
|
|
21
|
|
22
|
@Test
|
23
|
public void parserTest() throws IOException, MDStoreServiceException, IndexFieldRecordParserException {
|
24
|
InputStream inputStream = this.getClass().getResourceAsStream("/eu/dnetlib/data/mdstore/modular/mongodb/inputRecord.xml");
|
25
|
|
26
|
final String inputRecord = IOUtils.toString(inputStream);
|
27
|
|
28
|
final IndexFieldRecordParser parser = new IndexFieldRecordParser();
|
29
|
|
30
|
final List<MDFormatDescription> mdref = new ArrayList<>();
|
31
|
|
32
|
mdref.add(new MDFormatDescription("id", "//*[local-name()='objIdentifier']"));
|
33
|
mdref.add(new MDFormatDescription("title", "//*[local-name()='title']"));
|
34
|
mdref.add(new MDFormatDescription("creator", "//*[local-name()='creator']"));
|
35
|
|
36
|
Map<String, List<String>> stringListMap = parser.parseRecord(inputRecord, mdref);
|
37
|
|
38
|
|
39
|
for (String key : stringListMap.keySet()) {
|
40
|
System.out.println("key = " + key);
|
41
|
for (String value : stringListMap.get(key)) {
|
42
|
System.out.println("\t" + value);
|
43
|
}
|
44
|
|
45
|
}
|
46
|
|
47
|
|
48
|
}
|
49
|
|
50
|
|
51
|
}
|