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.urls.api.UrlProviderFactoryI;
24 import jalview.urls.api.UrlProviderI;
25 import jalview.urls.applet.AppletUrlProviderFactory;
26 import jalview.util.UrlConstants;
28 import java.util.HashMap;
29 import java.util.List;
32 import org.testng.Assert;
33 import org.testng.annotations.Test;
35 public class AppletUrlProviderFactoryTest {
37 @Test(groups = { "Functional" })
38 public void testCreateUrlProvider()
40 final String defaultUrl = UrlConstants.DEFAULT_STRING.substring(
41 UrlConstants.DEFAULT_STRING.indexOf(UrlConstants.SEP) + 1,
42 UrlConstants.DEFAULT_STRING.length());
43 Map<String, String> urlList = new HashMap<String, String>()
46 put("Test1", "http://identifiers.org/uniprot/$DB_ACCESSION$");
47 put("Test2", defaultUrl);
51 UrlProviderFactoryI factory = new AppletUrlProviderFactory("Test2",
53 UrlProviderI prov = factory.createUrlProvider();
55 // default url correctly set
56 Assert.assertEquals(prov.getPrimaryUrlId(), "Test2");
57 Assert.assertEquals(prov.getPrimaryUrl("FER_CAPAN"),
58 defaultUrl.replace("$SEQUENCE_ID$",
61 List<UrlLinkDisplay> allLinks = prov.getLinksForTable();
63 // 2 links in provider
64 Assert.assertEquals(allLinks.size(), 2);
66 // first link set correctly
67 Assert.assertEquals(allLinks.get(0).getId(), "Test1");
68 Assert.assertEquals(allLinks.get(0).getDescription(), "Test1");
69 Assert.assertEquals(allLinks.get(0).getUrl(),
70 "http://identifiers.org/uniprot/$DB_ACCESSION$");
71 Assert.assertFalse(allLinks.get(0).getIsPrimary());
72 Assert.assertTrue(allLinks.get(0).getIsSelected());
74 // second link set correctly
75 Assert.assertEquals(allLinks.get(1).getId(), "Test2");
76 Assert.assertEquals(allLinks.get(1).getDescription(), "Test2");
77 Assert.assertEquals(allLinks.get(1).getUrl(), defaultUrl);
78 Assert.assertTrue(allLinks.get(1).getIsPrimary());
79 Assert.assertTrue(allLinks.get(1).getIsSelected());