package eu.dnetlib.data.claims.parser;

import eu.dnetlib.data.claims.utils.ContextUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by argirok on 29/5/2018.
 */
public class ContextUtilsTest {
    ContextUtils contextUtils;

    @Before
    public void init() throws Exception {
        Configurator.initialize(new DefaultConfiguration());
        Configurator.setRootLevel(Level.INFO);
        ApplicationContext context = new ClassPathXmlApplicationContext("eu/dnetlib/data/claims/springContext-claims.xml");

        contextUtils = context.getBean(ContextUtils.class);


    }
    @Test
    public void dmf2ContextTest() throws Exception {

        String id= "egi::country::gr";

        Assert.assertEquals("EGI Federation> EGI Countries> Greece", contextUtils.extractLabel(id));
        id= "egi";
        Assert.assertEquals("EGI Federation", contextUtils.extractLabel(id));
        id="egi::classification";
        Assert.assertEquals("EGI Federation> EGI classification scheme", contextUtils.extractLabel(id));
        id="egi::classification::natsc";
        Assert.assertEquals("EGI Federation> EGI classification scheme> Natural Sciences", contextUtils.extractLabel(id));
        id="egi::classification::natsc::math";
        Assert.assertEquals("EGI Federation> EGI classification scheme> Mathematics", contextUtils.extractLabel(id));
        id="egi::classification::natsc::math::applied";
        Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", contextUtils.extractLabel(id));
        id="egi::classification::natsc::math::applied";
        Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", contextUtils.extractLabel(id));

/*

0
id	"aginfra::projects"
label	"AGINFRA+ Projects"
1
id	"aginfra::subcommunity"
label	"AGINFRA+ communities"
0
id	"aginfra::projects::1"
label	"European Foodbusiness Transfer Laboratory for stimulating entrepreneurial skills, for fostering innovation and for business creation in the Food Sector"
concepts
 */
    }
}
