Project

General

Profile

Download (2.39 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.ext.bci;
5

    
6
import java.util.List;
7

    
8
import org.junit.Assert;
9
import org.junit.Before;
10
import org.junit.Ignore;
11
import org.junit.Test;
12

    
13
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
14
import eu.etaxonomy.cdm.ext.ipni.IIpniService;
15
import eu.etaxonomy.cdm.model.occurrence.Collection;
16

    
17
/**
18
 * @author a.mueller
19
 *
20
 */
21
public class BciServiceTest {
22
	
23
	static String strUrl1;
24

    
25
	private IBciServiceWrapper service1;
26
	
27
	/**
28
	 * @throws java.lang.Exception
29
	 */
30
	@Before
31
	public void setUp() throws Exception {
32
		service1 = new BciServiceWrapper();
33
	}
34

    
35
// ******************************* TESTS ******************************************************/
36
	
37
	/**
38
	 * Test method for {@link eu.etaxonomy.cdm.ext.bci.BciServiceWrapper#BciService(java.net.URL)}.
39
	 */
40
	@Test
41
	public void testBciService() {
42
		Assert.assertNotNull("Service should not be null", service1);
43
		Assert.assertNotNull("URL1 should not be null", service1.getServiceUrl(IIpniService.ADVANCED_NAME_SERVICE_URL));
44
	}
45

    
46
	@Test
47
	@Ignore // service is under refactoring 
48
	public void testGetCollectionsByCode(){
49
		ICdmApplicationConfiguration config = null;
50
		List<Collection> collectionList = service1.getCollectionsByCode("BG", config);
51
		//expected web service result: urn:lsid:biocol.org:col:15727	http://biocol.org/urn:lsid:biocol.org:col:15727	University of Bergen Herbarium
52

    
53
		Assert.assertEquals("There should be exactly 1 result for 'BG'", 1, collectionList.size());
54
		Collection collection = collectionList.get(0);
55
		//title cache
56
		Assert.assertEquals("Name for BG should be 'University of Bergen Herbarium'", "University of Bergen Herbarium", collection.getName());
57
		Assert.assertEquals("LSID should be urn:lsid:biocol.org:col:15727", "urn:lsid:biocol.org:col:15727", collection.getLsid().getLsid());
58
		
59
		collectionList = service1.getCollectionsByCode("CM", config);
60
		Assert.assertEquals("There should be exactly 3 result for 'CM'. If not try http://www.biocol.org/rest/lookup/code/CM", 3, collectionList.size());
61
		
62
	}
63
	
64

    
65
	
66
	/**
67
	 * Test method for {@link eu.etaxonomy.cdm.ext.ipni.IpniService#getServiceUrl()}.
68
	 */
69
	@Test
70
	public void testGetServiceUrl() {
71
		Assert.assertNotNull("Service should not be null", service1);
72
		Assert.assertNotNull("URL1 should not be null", service1.getServiceUrl(IBciServiceWrapper.LOOKUP_CODE_REST));
73
	}
74

    
75

    
76
}
    (1-1/1)