3 import jalview.util.UrlLink;
7 import org.testng.Assert;
8 import org.testng.annotations.Test;
10 public class UrlLinkDisplayTest {
12 @Test(groups = { "Functional" })
13 public void testDisplayColumnNames()
15 // 5 column names returned although 6 names internal to UrlLinkDisplay
16 List<String> names = UrlLinkDisplay.getDisplayColumnNames();
17 Assert.assertEquals(names.size(), 5);
20 @Test(groups = { "Functional" })
21 public void getValue()
23 UrlLink link = new UrlLink("Test Name",
24 "http://identifiers.org/$DB_ACCESSION$", "TestDB");
25 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
27 Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.PRIMARY));
28 Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "Test");
29 Assert.assertEquals(u.getValue(UrlLinkDisplay.DATABASE), "TestDB");
30 Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "Test Name");
31 Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.SELECTED));
32 Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
33 "http://identifiers.org/$DB_ACCESSION$");
36 @Test(groups = { "Functional" })
37 public void testIsEditable()
39 // only default and selected columns are editable ever
40 // default only editable if link contains $SEQUENCE_ID$
42 UrlLink link = new UrlLink("Test Url",
43 "http://identifiers.org/$DB_ACCESSION$",
45 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
47 Assert.assertFalse(u.isEditable(UrlLinkDisplay.PRIMARY));
48 Assert.assertTrue(u.isEditable(UrlLinkDisplay.SELECTED));
49 Assert.assertFalse(u.isEditable(UrlLinkDisplay.ID));
50 Assert.assertFalse(u.isEditable(UrlLinkDisplay.URL));
51 Assert.assertFalse(u.isEditable(UrlLinkDisplay.NAME));
52 Assert.assertFalse(u.isEditable(UrlLinkDisplay.DATABASE));
54 UrlLink vlink = new UrlLink("Test Sequence ID Url",
55 "http://myurl/$SEQUENCE_ID$", "TestName");
56 UrlLinkDisplay v = new UrlLinkDisplay("Test", vlink, false, false);
58 Assert.assertTrue(v.isEditable(UrlLinkDisplay.PRIMARY));
59 Assert.assertTrue(v.isEditable(UrlLinkDisplay.SELECTED));
60 Assert.assertFalse(v.isEditable(UrlLinkDisplay.ID));
61 Assert.assertFalse(v.isEditable(UrlLinkDisplay.URL));
62 Assert.assertFalse(v.isEditable(UrlLinkDisplay.NAME));
63 Assert.assertFalse(v.isEditable(UrlLinkDisplay.DATABASE));
66 @Test(groups = { "Functional" })
67 public void testName()
69 UrlLink link = new UrlLink("Test Url",
70 "http://identifiers.org/$DB_ACCESSION$", "TestName");
71 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
73 // Name initially as input in link
74 Assert.assertEquals(u.getDBName(), "TestName");
76 // Setting updates name
77 u.setDBName("NewName");
78 Assert.assertEquals(u.getDBName(), "NewName");
81 @Test(groups = { "Functional" })
82 public void testDescription()
84 UrlLink link = new UrlLink("Test Name",
85 "http://identifiers.org/$DB_ACCESSION$", "TestDB");
86 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
88 // Desc initially as input in link
89 Assert.assertEquals(u.getDescription(), "Test Name");
91 // Setting updates name
92 u.setDescription("New Desc");
93 Assert.assertEquals(u.getDescription(), "New Desc");
96 @Test(groups = { "Functional" })
99 UrlLink link = new UrlLink("Test Name",
100 "http://identifiers.org/$DB_ACCESSION$", "TestDB");
101 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
103 // Url initially as input in link
104 Assert.assertEquals(u.getUrl(), "http://identifiers.org/$DB_ACCESSION$");
106 // Setting updates url
107 u.setUrl("http://something.new/$SEQUENCE_ID$");
108 Assert.assertEquals(u.getUrl(), "http://something.new/$SEQUENCE_ID$");
111 @Test(groups = { "Functional" })
112 public void testGetSetValue()
114 UrlLink link = new UrlLink("Test Name",
115 "http://identifiers.org/$DB_ACCESSION$", "TestDB");
116 UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
118 Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.PRIMARY));
119 Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.SELECTED));
120 Assert.assertEquals(u.getValue(UrlLinkDisplay.DATABASE), "TestDB");
121 Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "Test Name");
122 Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "Test");
123 Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
124 "http://identifiers.org/$DB_ACCESSION$");
126 u.setValue(UrlLinkDisplay.PRIMARY, true);
127 Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.PRIMARY));
129 u.setValue(UrlLinkDisplay.SELECTED, true);
130 Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.SELECTED));
132 u.setValue(UrlLinkDisplay.NAME, "New Desc");
133 Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "New Desc");
135 u.setValue(UrlLinkDisplay.DATABASE, "NewName");
136 Assert.assertEquals(u.getValue(UrlLinkDisplay.DATABASE), "NewName");
138 u.setValue(UrlLinkDisplay.ID, "New ID");
139 Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "New ID");
141 u.setValue(UrlLinkDisplay.URL, "http://something.new/$SEQUENCE_ID$");
142 Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
143 "http://something.new/$SEQUENCE_ID$");