2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.description
;
12 import static org
.junit
.Assert
.*;
14 import java
.awt
.Color
;
15 import java
.util
.HashMap
;
16 import java
.util
.HashSet
;
19 import java
.util
.UUID
;
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
;
28 import eu
.etaxonomy
.cdm
.model
.location
.TdwgArea
;
35 public class DistributionTest
{
36 private static final Logger logger
= Logger
.getLogger(DistributionTest
.class);
39 * @throws java.lang.Exception
42 public static void setUpBeforeClass() throws Exception
{
46 * @throws java.lang.Exception
49 public static void tearDownAfterClass() throws Exception
{
53 * @throws java.lang.Exception
56 public void setUp() throws Exception
{
60 * @throws java.lang.Exception
63 public void tearDown() throws Exception
{
66 //******************************************** TESTS**************
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"));