Project

General

Profile

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

    
3
import eu.dnetlib.data.claims.migration.entity.Relation;
4
import eu.dnetlib.data.claimsDemo.ClaimUtils;
5
import org.junit.Assert;
6
import org.junit.Test;
7

    
8
/**
9
 * Created by kiatrop on 9/2/2016.
10
 */
11
public class RelationParserTest {
12

    
13
    private final String projectResultXml =
14
            "<RELATIONS>" +
15
                    "<RELATION type='resultProject' source='50|od______2367::63368dc45b69d3eac6bf94b0181b4e64' target='40|corda_______::fe4cbcc8f465c016c034a4f93965074c' />" +
16
                    "</RELATIONS>";
17

    
18
    private final String publicationDatasetXml =
19
            "<RELATIONS>" +
20
                    "<RELATION type='resultResult_publicationdataset_isRelatedTo' source='50|dedup_wf_001::f81ff2795647ddd5756b046c026e22ec' target='50|datacite____::6302a4307468b410343413c04b11453b' />" +
21
                    "</RELATIONS>";
22

    
23
    private final String datasetPublicationXml =
24
            "<RELATIONS>" +
25
                    "<RELATION type='resultResult_datasetpublication_isRelatedTo' source='50|r37b0ad08687::f016cea0f48814bea455804017883872' target='50|crossref____::68178723a3e54b2ab18acb8e2859ddaf' />" +
26
                    "</RELATIONS>";
27

    
28

    
29
    @Test
30
    public void xml2Relation_projectResult_test() {
31
        Relation relation = RelationParser.xml2Relation(projectResultXml);
32
        Assert.assertEquals(relation.getSourceId(), "corda_______::fe4cbcc8f465c016c034a4f93965074c");
33
        Assert.assertEquals(relation.getSourceType(), ClaimUtils.PROJECT);
34
        Assert.assertEquals(relation.getTargetId(), "od______2367::63368dc45b69d3eac6bf94b0181b4e64");
35
        Assert.assertEquals(relation.getTargetType(), ClaimUtils.PUBLICATION);
36
    }
37

    
38
    @Test
39
    public void xml2Relation_publicationDataset_test() {
40
        Relation relation = RelationParser.xml2Relation(publicationDatasetXml);
41
        Assert.assertEquals(relation.getSourceId(), "datacite____::6302a4307468b410343413c04b11453b");
42
        Assert.assertEquals(relation.getSourceType(), ClaimUtils.DATASET);
43
        Assert.assertEquals(relation.getTargetId(), "dedup_wf_001::f81ff2795647ddd5756b046c026e22ec");
44
        Assert.assertEquals(relation.getTargetType(), ClaimUtils.PUBLICATION);
45
    }
46

    
47
    @Test
48
    public void xml2Relation_datasetPublication_test() {
49
        Relation relation = RelationParser.xml2Relation(datasetPublicationXml);
50
        Assert.assertEquals(relation.getSourceId(), "crossref____::68178723a3e54b2ab18acb8e2859ddaf");
51
        Assert.assertEquals(relation.getSourceType(), ClaimUtils.PUBLICATION);
52
        Assert.assertEquals(relation.getTargetId(), "r37b0ad08687::f016cea0f48814bea455804017883872");
53
        Assert.assertEquals(relation.getTargetType(), ClaimUtils.DATASET);
54
    }
55

    
56
}
(5-5/5)