Project

General

Profile

1
package eu.dnetlib.data.claims.parser;
2

    
3
import eu.dnetlib.data.claims.utils.ContextUtils;
4
import org.apache.logging.log4j.Level;
5
import org.apache.logging.log4j.core.config.Configurator;
6
import org.apache.logging.log4j.core.config.DefaultConfiguration;
7
import org.junit.Assert;
8
import org.junit.Before;
9
import org.junit.Test;
10
import org.springframework.context.ApplicationContext;
11
import org.springframework.context.support.ClassPathXmlApplicationContext;
12

    
13
/**
14
 * Created by argirok on 29/5/2018.
15
 */
16
public class ContextUtilsTest {
17
    ContextUtils contextUtils;
18

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

    
25
        contextUtils = context.getBean(ContextUtils.class);
26

    
27

    
28
    }
29
    @Test
30
    public void dmf2ContextTest() throws Exception {
31

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

    
34
        Assert.assertEquals("EGI Federation> EGI Countries> Greece", contextUtils.extractLabel(id));
35
        id= "egi";
36
        Assert.assertEquals("EGI Federation", contextUtils.extractLabel(id));
37
        id="egi::classification";
38
        Assert.assertEquals("EGI Federation> EGI classification scheme", contextUtils.extractLabel(id));
39
        id="egi::classification::natsc";
40
        Assert.assertEquals("EGI Federation> EGI classification scheme> Natural Sciences", contextUtils.extractLabel(id));
41
        id="egi::classification::natsc::math";
42
        Assert.assertEquals("EGI Federation> EGI classification scheme> Mathematics", contextUtils.extractLabel(id));
43
        id="egi::classification::natsc::math::applied";
44
        Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", contextUtils.extractLabel(id));
45
        id="egi::classification::natsc::math::applied";
46
        Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", contextUtils.extractLabel(id));
47

    
48
/*
49

    
50
0
51
id	"aginfra::projects"
52
label	"AGINFRA+ Projects"
53
1
54
id	"aginfra::subcommunity"
55
label	"AGINFRA+ communities"
56
0
57
id	"aginfra::projects::1"
58
label	"European Foodbusiness Transfer Laboratory for stimulating entrepreneurial skills, for fostering innovation and for business creation in the Food Sector"
59
concepts
60
 */
61
    }
62
}
(1-1/3)