2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.util.UrlConstants;
25 import java.util.HashMap;
26 import java.util.List;
29 import org.testng.Assert;
30 import org.testng.annotations.Test;
32 public class AppletUrlProviderFactoryTest {
34 @Test(groups = { "Functional" })
35 public void testCreateUrlProvider()
37 final String defaultUrl = UrlConstants.DEFAULT_STRING.substring(
38 UrlConstants.DEFAULT_STRING.indexOf(UrlConstants.SEP) + 1,
39 UrlConstants.DEFAULT_STRING.length());
40 Map<String, String> urlList = new HashMap<String, String>()
43 put("Test1", "http://identifiers.org/uniprot/$DB_ACCESSION$");
44 put("Test2", defaultUrl);
48 UrlProviderFactoryI factory = new AppletUrlProviderFactory("Test2",
50 UrlProviderI prov = factory.createUrlProvider();
52 // default url correctly set
53 Assert.assertEquals(prov.getDefaultUrlId(), "Test2");
54 Assert.assertEquals(prov.getDefaultUrl("FER_CAPAN"),
55 defaultUrl.replace("$SEQUENCE_ID$",
58 List<UrlLinkDisplay> allLinks = prov.getLinksForTable();
60 // 2 links in provider
61 Assert.assertEquals(allLinks.size(), 2);
63 // first link set correctly
64 Assert.assertEquals(allLinks.get(0).getId(), "Test1");
65 Assert.assertEquals(allLinks.get(0).getName(), "Test1");
66 Assert.assertEquals(allLinks.get(0).getUrl(),
67 "http://identifiers.org/uniprot/$DB_ACCESSION$");
68 Assert.assertFalse(allLinks.get(0).getIsDefault());
69 Assert.assertTrue(allLinks.get(0).getIsSelected());
71 // second link set correctly
72 Assert.assertEquals(allLinks.get(1).getId(), "Test2");
73 Assert.assertEquals(allLinks.get(1).getName(), "Test2");
74 Assert.assertEquals(allLinks.get(1).getUrl(), defaultUrl);
75 Assert.assertTrue(allLinks.get(1).getIsDefault());
76 Assert.assertTrue(allLinks.get(1).getIsSelected());