1
|
package eu.dnetlib.data.transform.xml;
|
2
|
|
3
|
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
|
4
|
import org.apache.commons.io.IOUtils;
|
5
|
import org.junit.After;
|
6
|
import org.junit.Before;
|
7
|
import org.junit.Test;
|
8
|
|
9
|
import java.util.List;
|
10
|
|
11
|
import static org.junit.Assert.assertEquals;
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
* Created by miriam on 04/05/2017.
|
16
|
*/
|
17
|
public class FWDXsltFunctionsTest {
|
18
|
private String namesurname ="Gerhard SOMMER";
|
19
|
private String noSurname = "Gerhard";
|
20
|
private String noName = "SOMMER";
|
21
|
private String twoNames = "Gerhard Pippo SOMMER";
|
22
|
private String twoSurname = "Gerhard PIPPO SOMMER";
|
23
|
private String nonamesurname = "";
|
24
|
|
25
|
@Before
|
26
|
public void before() throws Exception {
|
27
|
}
|
28
|
|
29
|
@After
|
30
|
public void after() throws Exception {
|
31
|
}
|
32
|
|
33
|
@Test
|
34
|
public void testGetNamesNameNoNameSurname() throws Exception {
|
35
|
String ret = FWFXsltFunctions.getName(nonamesurname,true);
|
36
|
assertEquals("",ret );
|
37
|
}
|
38
|
|
39
|
@Test
|
40
|
public void testGetNamesSurnameNoNameSurname() throws Exception {
|
41
|
String ret = FWFXsltFunctions.getName(nonamesurname,false);
|
42
|
assertEquals("",ret );
|
43
|
}
|
44
|
|
45
|
@Test
|
46
|
public void testGetNamesNameTwoSurname() throws Exception {
|
47
|
String ret = FWFXsltFunctions.getName(twoSurname,true);
|
48
|
assertEquals("Gerhard",ret );
|
49
|
}
|
50
|
|
51
|
@Test
|
52
|
public void testGetNamesSurnameTwoSurname() throws Exception {
|
53
|
String ret = FWFXsltFunctions.getName(twoSurname,false);
|
54
|
assertEquals("PIPPO SOMMER",ret );
|
55
|
}
|
56
|
|
57
|
@Test
|
58
|
public void testGetNamesNameTwoNames() throws Exception {
|
59
|
String ret = FWFXsltFunctions.getName(twoNames,true);
|
60
|
assertEquals("Gerhard Pippo",ret );
|
61
|
}
|
62
|
|
63
|
@Test
|
64
|
public void testGetNamesSurnameTwoNames() throws Exception {
|
65
|
String ret = FWFXsltFunctions.getName(twoNames,false);
|
66
|
assertEquals("SOMMER",ret );
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Method: getProvs(String jsonProvList)
|
71
|
*/
|
72
|
@Test
|
73
|
public void testGetNamesName() throws Exception {
|
74
|
String ret = FWFXsltFunctions.getName(namesurname,true);
|
75
|
assertEquals("Gerhard",ret );
|
76
|
}
|
77
|
|
78
|
@Test
|
79
|
public void testGetNamesSurname() throws Exception {
|
80
|
String ret = FWFXsltFunctions.getName(namesurname,false);
|
81
|
assertEquals("SOMMER",ret );
|
82
|
}
|
83
|
|
84
|
@Test
|
85
|
public void testGetNamesNameNoSurname() throws Exception {
|
86
|
String ret = FWFXsltFunctions.getName(noSurname,true);
|
87
|
assertEquals("Gerhard",ret );
|
88
|
}
|
89
|
|
90
|
@Test
|
91
|
public void testGetNamesSurnameNoSurname() throws Exception {
|
92
|
String ret = FWFXsltFunctions.getName(noSurname,false);
|
93
|
assertEquals("",ret );
|
94
|
}
|
95
|
|
96
|
@Test
|
97
|
public void testGetNamesNameNoName() throws Exception {
|
98
|
String ret = FWFXsltFunctions.getName(noName,true);
|
99
|
assertEquals("",ret );
|
100
|
}
|
101
|
|
102
|
@Test
|
103
|
public void testGetNamesSurnameNoName() throws Exception {
|
104
|
String ret = FWFXsltFunctions.getName(noName,false);
|
105
|
assertEquals("SOMMER",ret );
|
106
|
}
|
107
|
|
108
|
}
|