1
|
package eu.dnetlib.grid.process.utils;
|
2
|
|
3
|
import java.io.FileInputStream;
|
4
|
import java.io.FileNotFoundException;
|
5
|
import java.io.InputStream;
|
6
|
import java.util.HashSet;
|
7
|
import java.util.Set;
|
8
|
import java.util.stream.Collectors;
|
9
|
|
10
|
import org.junit.Before;
|
11
|
import org.junit.Test;
|
12
|
|
13
|
import eu.dnetlib.grid.process.model.GridOrganization;
|
14
|
|
15
|
public class GridUtilsTest {
|
16
|
|
17
|
@Before
|
18
|
public void setUp() throws Exception {}
|
19
|
|
20
|
@Test
|
21
|
public void test() throws FileNotFoundException {
|
22
|
// final InputStream is = getClass().getResourceAsStream("grid_example.json");
|
23
|
final InputStream is = new FileInputStream("/Users/michele/Desktop/grid.json");
|
24
|
int i = 0;
|
25
|
final Set<String> s = new HashSet<>();
|
26
|
for (final GridOrganization o : GridUtils.getOrganizations(is)) {
|
27
|
System.out.println(++i + " " + o.getId());
|
28
|
o.getAddresses().forEach(a -> s.add(a.getCountry_code()));
|
29
|
}
|
30
|
System.out.println(s.stream().collect(Collectors.joining(", ")));
|
31
|
|
32
|
}
|
33
|
|
34
|
}
|