1
|
package eu.dnetlib.openaire.exporter.funders;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.nio.charset.Charset;
|
5
|
import java.util.concurrent.LinkedBlockingQueue;
|
6
|
|
7
|
import com.google.gson.Gson;
|
8
|
import com.google.gson.GsonBuilder;
|
9
|
import eu.dnetlib.openaire.exporter.funders.context.Context;
|
10
|
import eu.dnetlib.openaire.exporter.funders.context.MappingUtils;
|
11
|
import eu.dnetlib.openaire.exporter.funders.model.FunderDetails;
|
12
|
import org.apache.commons.io.IOUtils;
|
13
|
import org.junit.Before;
|
14
|
import org.junit.Test;
|
15
|
|
16
|
import static org.junit.Assert.assertFalse;
|
17
|
import static org.junit.Assert.assertNotNull;
|
18
|
|
19
|
public class FunderContextClientTest {
|
20
|
|
21
|
private FunderDao fDao;
|
22
|
|
23
|
@Before
|
24
|
public void setUp() {
|
25
|
fDao = new FunderDao();
|
26
|
}
|
27
|
|
28
|
@Test
|
29
|
public void testParseContextProfile() throws IOException {
|
30
|
final String contextProfile = IOUtils.toString(getClass().getResourceAsStream("ec-fp7.xml"), Charset.defaultCharset());
|
31
|
final Context context = MappingUtils.parseContext(contextProfile, new LinkedBlockingQueue<>());
|
32
|
|
33
|
assertNotNull(context);
|
34
|
assertNotNull(context.getId());
|
35
|
|
36
|
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
37
|
final String json = gson.toJson(context);
|
38
|
assertNotNull(json);
|
39
|
assertFalse(json.isEmpty());
|
40
|
|
41
|
System.out.println(gson.toJson(gson.fromJson(json, Context.class)));
|
42
|
|
43
|
final FunderDetails funderDetails = MappingUtils.asFunderDetails(context);
|
44
|
System.out.println(gson.toJson(funderDetails));
|
45
|
|
46
|
}
|
47
|
|
48
|
}
|