(no commit message)
[cdmlib.git] / cdmlib-model / src / test / java / eu / etaxonomy / cdm / model / description / DistributionTest.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.model.description;
11
12 import static org.junit.Assert.*;
13
14 import java.awt.Color;
15 import java.util.HashMap;
16 import java.util.HashSet;
17 import java.util.Map;
18 import java.util.Set;
19 import java.util.UUID;
20
21 import org.apache.log4j.Logger;
22 import org.junit.After;
23 import org.junit.AfterClass;
24 import org.junit.Before;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27
28 import eu.etaxonomy.cdm.model.location.TdwgArea;
29
30 /**
31 * @author a.mueller
32 * @created 08.10.2008
33 * @version 1.0
34 */
35 public class DistributionTest {
36 private static final Logger logger = Logger.getLogger(DistributionTest.class);
37
38 /**
39 * @throws java.lang.Exception
40 */
41 @BeforeClass
42 public static void setUpBeforeClass() throws Exception {
43 }
44
45 /**
46 * @throws java.lang.Exception
47 */
48 @AfterClass
49 public static void tearDownAfterClass() throws Exception {
50 }
51
52 /**
53 * @throws java.lang.Exception
54 */
55 @Before
56 public void setUp() throws Exception {
57 }
58
59 /**
60 * @throws java.lang.Exception
61 */
62 @After
63 public void tearDown() throws Exception {
64 }
65
66 //******************************************** TESTS**************
67 @Test
68 public void testGetWebServiceUrl() {
69 String webServiceUrl = "http://www.test.de/webservice";
70 Set<Distribution> distributions = new HashSet<Distribution>();
71 distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("SPA"), PresenceTerm.PRESENT()));
72 distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("GER"), PresenceTerm.INTRODUCED()));
73 distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("14"), PresenceTerm.CULTIVATED()));
74 distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("BGM"), AbsenceTerm.ABSENT()));
75 distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("FRA"), AbsenceTerm.ABSENT()));
76 distributions.add(Distribution.NewInstance(TdwgArea.getAreaByTdwgAbbreviation("NFK-NI"), PresenceTerm.PRESENT()));
77 Map<PresenceAbsenceTermBase<?>, Color> presenceAbsenceColorMap = new HashMap<PresenceAbsenceTermBase<?>, Color>();
78 presenceAbsenceColorMap.put(PresenceTerm.PRESENT(), Color.BLUE);
79 presenceAbsenceColorMap.put(PresenceTerm.INTRODUCED(), Color.RED);
80 String result = Distribution.getEditGeoServiceUrlParameterString(distributions, presenceAbsenceColorMap, 600, 0, null);
81 //TODO Set semantics is not determined
82 String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";
83 System.out.println(result);
84 assertTrue(result.startsWith("l=tdwg"));
85 assertTrue(result.endsWith("&ms=600"));
86 //assertTrue(result.matches("0000ff"));
87 //TODO continue
88 }
89 }