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