2022-02-04 10:12:15 +01:00
|
|
|
package eu.dnetlib.openaire.funders;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
|
|
|
|
|
import eu.dnetlib.openaire.context.ContextMappingUtils;
|
2023-03-31 14:53:52 +02:00
|
|
|
import eu.dnetlib.openaire.exporter.model.context.Context;
|
|
|
|
import eu.dnetlib.openaire.exporter.model.funders.FunderDetails;
|
2022-02-04 10:12:15 +01:00
|
|
|
|
|
|
|
public class FunderContextClientTest {
|
|
|
|
|
2024-02-19 16:06:34 +01:00
|
|
|
private FunderService fDao;
|
2022-02-04 10:12:15 +01:00
|
|
|
|
|
|
|
@BeforeEach
|
|
|
|
public void setUp() {
|
2024-02-19 16:06:34 +01:00
|
|
|
fDao = new FunderService();
|
2022-02-04 10:12:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testParseContextProfile() throws IOException {
|
|
|
|
final String contextProfile = IOUtils.toString(getClass().getResourceAsStream("ec-fp7.xml"), Charset.defaultCharset());
|
|
|
|
final Context context = ContextMappingUtils.parseContext(contextProfile, new LinkedBlockingQueue<>());
|
|
|
|
|
|
|
|
assertNotNull(context);
|
|
|
|
assertNotNull(context.getId());
|
|
|
|
|
|
|
|
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
|
|
final String json = gson.toJson(context);
|
|
|
|
assertNotNull(json);
|
|
|
|
assertFalse(json.isEmpty());
|
|
|
|
|
|
|
|
// System.out.println(gson.toJson(gson.fromJson(json, Context.class)));
|
|
|
|
|
|
|
|
final FunderDetails funderDetails = ContextMappingUtils.asFunderDetails(context);
|
|
|
|
// System.out.println(gson.toJson(funderDetails));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|