1
|
package gr.uoa.di.driver.xml;
|
2
|
|
3
|
import static org.junit.Assert.assertEquals;
|
4
|
import static org.junit.Assert.assertNotNull;
|
5
|
|
6
|
import javax.xml.bind.JAXBException;
|
7
|
|
8
|
import org.junit.Test;
|
9
|
|
10
|
import eu.dnetlib.domain.functionality.Community;
|
11
|
|
12
|
public class TestCommunityXmlConverter {
|
13
|
|
14
|
|
15
|
@Test
|
16
|
public void test() throws JAXBException {
|
17
|
CommunityXmlConverter conv = new CommunityXmlConverter();
|
18
|
Community com = new Community();
|
19
|
|
20
|
com.setName("communityName");
|
21
|
com.setResourceId("42");
|
22
|
com.setOwner("ownerId");
|
23
|
com.setDescription("Looooong descriptioooooon");
|
24
|
com.getAuthoritativeDocuments().add("authId1");
|
25
|
com.getAuthoritativeDocuments().add("authId2");
|
26
|
com.getAuthoritativeDocuments().add("authId3");
|
27
|
com.getAuthoritativeDocuments().add("authId4");
|
28
|
|
29
|
String xml = conv.ObjectToXml(com);
|
30
|
assertNotNull(xml);
|
31
|
|
32
|
com = conv.XmlToObject(xml);
|
33
|
|
34
|
assertEquals("communityName", com.getName());
|
35
|
assertEquals("42", com.getResourceId());
|
36
|
assertEquals("ownerId", com.getOwner());
|
37
|
assertEquals("Looooong descriptioooooon", com.getDescription());
|
38
|
assertNotNull(com.getAuthoritativeDocuments());
|
39
|
assertEquals(4, com.getAuthoritativeDocuments().size());
|
40
|
}
|
41
|
|
42
|
@Test
|
43
|
public void testXml() throws JAXBException {
|
44
|
|
45
|
String xml = "<RESOURCE_PROFILE>" +
|
46
|
"<HEADER>" +
|
47
|
"<RESOURCE_IDENTIFIER value=\"1-b42e67bf-b0f4-4cd2-b364-3acae398ee0b_Q29tbXVuaXR5RFNSZXNvdXJjZXMvQ29tbXVuaXR5RFNSZXNvdXJjZVR5cGU=\"/>" +
|
48
|
"<RESOURCE_TYPE value=\"CommunityDSResourceType\"/>" +
|
49
|
"<RESOURCE_KIND value=\"CommunityDSResources\"/>" +
|
50
|
"<RESOURCE_URI value=\"http://146.48.87.216:8180/community/services/CommunityService?wsdl\"/>" +
|
51
|
"<DATE_OF_CREATION value=\"2008-02-15T09:48:11+01:00\"/>" +
|
52
|
"</HEADER>"+
|
53
|
"<BODY>" +
|
54
|
"<CONFIGURATION>" +
|
55
|
"<NAME value=\"Computer Science in the UK\"/>"+
|
56
|
"<OWNER value=\"26-1fd69d42-a0e7-4c2a-8029-14c24fc05dec_VXNlckRTUmVzb3VyY2VzL1VzZXJEU1Jlc291cmNlVHlwZQ==\"/>"+
|
57
|
"<DESCRIPTION value=\"Publications in Computer Science from Repositories in the UK\"/>" +
|
58
|
"<COLLECTIONS>" +
|
59
|
"<COLLECTION collection=\"22-8be06951-861f-44ac-9bd1-8a5a47df3c14_Q29sbGVjdGlvbkRTUmVzb3VyY2VzL0NvbGxlY3Rpb25EU1Jlc291cmNlVHlwZQ==\"/>"+
|
60
|
"<COLLECTION collection=\"32-46c93e25-f144-4665-bef2-f93856239328_Q29sbGVjdGlvbkRTUmVzb3VyY2VzL0NvbGxlY3Rpb25EU1Jlc291cmNlVHlwZQ==\"/>"+
|
61
|
"</COLLECTIONS>" +
|
62
|
"<MANAGERS/>" +
|
63
|
"<RECOMMENDATIONS/>" +
|
64
|
"</CONFIGURATION>" +
|
65
|
"<STATUS>value</STATUS>" +
|
66
|
"<SECURITY_PARAMETERS SECURITY_PARAMETER=\"Security Parameters\"/>" +
|
67
|
"</BODY>" +
|
68
|
"</RESOURCE_PROFILE>";
|
69
|
|
70
|
CommunityXmlConverter conv = new CommunityXmlConverter();
|
71
|
conv.XmlToObject(xml);
|
72
|
}
|
73
|
|
74
|
}
|