Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 15:05:32 GMT
  2. Package jalview.urls

File UrlLinkDisplayTest.java

 

Code metrics

0
62
7
1
167
109
7
0.11
8.86
7
1

Classes

Class Line # Actions
UrlLinkDisplayTest 30 62 7
1.0100%
 

Contributing tests

This file is covered by 7 tests. .

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.util.UrlLink;
24   
25    import java.util.List;
26   
27    import org.testng.Assert;
28    import org.testng.annotations.Test;
29   
 
30    public class UrlLinkDisplayTest
31    {
32   
 
33  1 toggle @Test(groups = { "Functional" })
34    public void testDisplayColumnNames()
35    {
36    // 5 column names returned although 6 names internal to UrlLinkDisplay
37  1 List<String> names = UrlLinkDisplay.getDisplayColumnNames();
38  1 Assert.assertEquals(names.size(), 5);
39    }
40   
 
41  1 toggle @Test(groups = { "Functional" })
42    public void getValue()
43    {
44  1 UrlLink link = new UrlLink("Test Name",
45    "http://identifiers.org/$DB_ACCESSION$", "TestDB");
46  1 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
47   
48  1 Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.PRIMARY));
49  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "Test");
50  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.DATABASE), "TestDB");
51  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "Test Name");
52  1 Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.SELECTED));
53  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
54    "http://identifiers.org/$DB_ACCESSION$");
55    }
56   
 
57  1 toggle @Test(groups = { "Functional" })
58    public void testIsEditable()
59    {
60    // only default and selected columns are editable ever
61    // default only editable if link contains $SEQUENCE_ID$
62   
63  1 UrlLink link = new UrlLink("Test Url",
64    "http://identifiers.org/$DB_ACCESSION$", "TestName");
65  1 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
66   
67  1 Assert.assertFalse(u.isEditable(UrlLinkDisplay.PRIMARY));
68  1 Assert.assertTrue(u.isEditable(UrlLinkDisplay.SELECTED));
69  1 Assert.assertFalse(u.isEditable(UrlLinkDisplay.ID));
70  1 Assert.assertFalse(u.isEditable(UrlLinkDisplay.URL));
71  1 Assert.assertFalse(u.isEditable(UrlLinkDisplay.NAME));
72  1 Assert.assertFalse(u.isEditable(UrlLinkDisplay.DATABASE));
73   
74  1 UrlLink vlink = new UrlLink("Test Sequence ID Url",
75    "http://myurl/$SEQUENCE_ID$", "TestName");
76  1 UrlLinkDisplay v = new UrlLinkDisplay("Test", vlink, false, false);
77   
78  1 Assert.assertTrue(v.isEditable(UrlLinkDisplay.PRIMARY));
79  1 Assert.assertTrue(v.isEditable(UrlLinkDisplay.SELECTED));
80  1 Assert.assertFalse(v.isEditable(UrlLinkDisplay.ID));
81  1 Assert.assertFalse(v.isEditable(UrlLinkDisplay.URL));
82  1 Assert.assertFalse(v.isEditable(UrlLinkDisplay.NAME));
83  1 Assert.assertFalse(v.isEditable(UrlLinkDisplay.DATABASE));
84    }
85   
 
86  1 toggle @Test(groups = { "Functional" })
87    public void testName()
88    {
89  1 UrlLink link = new UrlLink("Test Url",
90    "http://identifiers.org/$DB_ACCESSION$", "TestName");
91  1 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
92   
93    // Name initially as input in link
94  1 Assert.assertEquals(u.getDBName(), "TestName");
95   
96    // Setting updates name
97  1 u.setDBName("NewName");
98  1 Assert.assertEquals(u.getDBName(), "NewName");
99    }
100   
 
101  1 toggle @Test(groups = { "Functional" })
102    public void testDescription()
103    {
104  1 UrlLink link = new UrlLink("Test Name",
105    "http://identifiers.org/$DB_ACCESSION$", "TestDB");
106  1 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
107   
108    // Desc initially as input in link
109  1 Assert.assertEquals(u.getDescription(), "Test Name");
110   
111    // Setting updates name
112  1 u.setDescription("New Desc");
113  1 Assert.assertEquals(u.getDescription(), "New Desc");
114    }
115   
 
116  1 toggle @Test(groups = { "Functional" })
117    public void testUrl()
118    {
119  1 UrlLink link = new UrlLink("Test Name",
120    "http://identifiers.org/$DB_ACCESSION$", "TestDB");
121  1 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
122   
123    // Url initially as input in link
124  1 Assert.assertEquals(u.getUrl(),
125    "http://identifiers.org/$DB_ACCESSION$");
126   
127    // Setting updates url
128  1 u.setUrl("http://something.new/$SEQUENCE_ID$");
129  1 Assert.assertEquals(u.getUrl(), "http://something.new/$SEQUENCE_ID$");
130    }
131   
 
132  1 toggle @Test(groups = { "Functional" })
133    public void testGetSetValue()
134    {
135  1 UrlLink link = new UrlLink("Test Name",
136    "http://identifiers.org/$DB_ACCESSION$", "TestDB");
137  1 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
138   
139  1 Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.PRIMARY));
140  1 Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.SELECTED));
141  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.DATABASE), "TestDB");
142  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "Test Name");
143  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "Test");
144  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
145    "http://identifiers.org/$DB_ACCESSION$");
146   
147  1 u.setValue(UrlLinkDisplay.PRIMARY, true);
148  1 Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.PRIMARY));
149   
150  1 u.setValue(UrlLinkDisplay.SELECTED, true);
151  1 Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.SELECTED));
152   
153  1 u.setValue(UrlLinkDisplay.NAME, "New Desc");
154  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "New Desc");
155  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.DATABASE), "New Desc");
156   
157  1 u.setValue(UrlLinkDisplay.DATABASE, "NewName");
158  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.DATABASE), "NewName");
159   
160  1 u.setValue(UrlLinkDisplay.ID, "New ID");
161  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "New ID");
162   
163  1 u.setValue(UrlLinkDisplay.URL, "http://something.new/$SEQUENCE_ID$");
164  1 Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
165    "http://something.new/$SEQUENCE_ID$");
166    }
167    }