1
|
package eu.dnetlib.data.collector.plugins.excel;
|
2
|
|
3
|
import eu.dnetlib.data.collector.plugins.HttpCSVCollectorPlugin;
|
4
|
import eu.dnetlib.data.collector.rmi.InterfaceDescriptor;
|
5
|
import org.junit.Assert;
|
6
|
import org.junit.Before;
|
7
|
import org.junit.Test;
|
8
|
|
9
|
import java.util.HashMap;
|
10
|
import java.util.Iterator;
|
11
|
/**
|
12
|
* Created by miriam on 10/05/2017.
|
13
|
*/
|
14
|
public class ReadExcelTest {
|
15
|
private InterfaceDescriptor descr;
|
16
|
private Read r;
|
17
|
private Object asserNotNul;
|
18
|
|
19
|
@Before
|
20
|
public void setUp() throws Exception {
|
21
|
descr = new InterfaceDescriptor();
|
22
|
descr.setBaseUrl("https://pf.fwf.ac.at/en/research-in-practice/project-finder.xlsx?&&&search%5Bcall%5D=&search%5Bdecision_board_ids%5D=&search%5Bend_date%5D=&search%5Binstitute_name%5D=&search%5Blead_firstname%5D=&search%5Blead_lastname%5D=&search%5Bper_page%5D=10&search%5Bproject_number%5D=&search%5Bproject_title%5D=&search%5Bscience_discipline_id%5D=&search%5Bstart_date%5D=&search%5Bstatus_id%5D=&search%5Bwhat%5D=&action=index&controller=projects&locale=en&per_page=10" );
|
23
|
HashMap<String, String> params = new HashMap<String, String>();
|
24
|
|
25
|
params.put("argument", "{\"replace\":{\"header\":[{\"from\":\"&\",\"to\":\"and\"}],\"body\":[{\"from\":\"\\n\",\"to\":\" \"}]}," +
|
26
|
"\"replace_currency\":[{\"from\":\"$\",\"to\":\"€\"}],\"col_currency\":10}");
|
27
|
params.put("header_row","4");
|
28
|
params.put("tmp_file","//tmp//fwf.xslx");
|
29
|
params.put("remove_empty_lines","yes");
|
30
|
params.put("remove_lines_with_id"," – ");
|
31
|
params.put("col_id","1");
|
32
|
params.put("remove_tmp_file","no");
|
33
|
params.put("sheet_number","0");
|
34
|
params.put("file_to_save","/tmp/project_search.2017.05.10.csv");
|
35
|
params.put("separator", ",");
|
36
|
params.put("quote","\"");
|
37
|
descr.setParams(params);
|
38
|
|
39
|
r = new Read(descr);
|
40
|
r.setCollector(new HttpCSVCollectorPlugin());
|
41
|
}
|
42
|
|
43
|
@Test
|
44
|
public void readExcelFromUrl()throws Exception{
|
45
|
Iterator<String> it = r.parseFile().iterator();
|
46
|
|
47
|
while(it.hasNext()){
|
48
|
Assert.assertNotNull(it.next());
|
49
|
//System.out.println(it.next());
|
50
|
}
|
51
|
|
52
|
|
53
|
}
|
54
|
}
|