Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package jalview.urls

File AppletUrlProviderFactoryTest.java

 

Code metrics

0
20
2
1
81
46
2
0.1
10
2
1

Classes

Class Line # Actions
AppletUrlProviderFactoryTest 35 20 2
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.urls;
22   
23    import jalview.urls.api.UrlProviderFactoryI;
24    import jalview.urls.api.UrlProviderI;
25    import jalview.urls.applet.AppletUrlProviderFactory;
26    import jalview.util.UrlConstants;
27   
28    import java.util.HashMap;
29    import java.util.List;
30    import java.util.Map;
31   
32    import org.testng.Assert;
33    import org.testng.annotations.Test;
34   
 
35    public class AppletUrlProviderFactoryTest {
36   
 
37  1 toggle @Test(groups = { "Functional" })
38    public void testCreateUrlProvider()
39    {
40  1 final String defaultUrl = UrlConstants.DEFAULT_STRING.substring(
41    UrlConstants.DEFAULT_STRING.indexOf(UrlConstants.SEP) + 1,
42    UrlConstants.DEFAULT_STRING.length());
43  1 Map<String, String> urlList = new HashMap<String, String>()
44    {
 
45  1 toggle {
46  1 put("Test1", "http://identifiers.org/uniprot/$DB_ACCESSION$");
47  1 put("Test2", defaultUrl);
48    }
49    };
50   
51  1 UrlProviderFactoryI factory = new AppletUrlProviderFactory("Test2",
52    urlList);
53  1 UrlProviderI prov = factory.createUrlProvider();
54   
55    // default url correctly set
56  1 Assert.assertEquals(prov.getPrimaryUrlId(), "Test2");
57  1 Assert.assertEquals(prov.getPrimaryUrl("FER_CAPAN"),
58    defaultUrl.replace("$SEQUENCE_ID$",
59    "FER_CAPAN"));
60   
61  1 List<UrlLinkDisplay> allLinks = prov.getLinksForTable();
62   
63    // 2 links in provider
64  1 Assert.assertEquals(allLinks.size(), 2);
65   
66    // first link set correctly
67  1 Assert.assertEquals(allLinks.get(0).getId(), "Test1");
68  1 Assert.assertEquals(allLinks.get(0).getDescription(), "Test1");
69  1 Assert.assertEquals(allLinks.get(0).getUrl(),
70    "http://identifiers.org/uniprot/$DB_ACCESSION$");
71  1 Assert.assertFalse(allLinks.get(0).getIsPrimary());
72  1 Assert.assertTrue(allLinks.get(0).getIsSelected());
73   
74    // second link set correctly
75  1 Assert.assertEquals(allLinks.get(1).getId(), "Test2");
76  1 Assert.assertEquals(allLinks.get(1).getDescription(), "Test2");
77  1 Assert.assertEquals(allLinks.get(1).getUrl(), defaultUrl);
78  1 Assert.assertTrue(allLinks.get(1).getIsPrimary());
79  1 Assert.assertTrue(allLinks.get(1).getIsSelected());
80    }
81    }