--- /dev/null
+package jalview.urls;
+
+import jalview.util.UrlLink;
+
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class UrlLinkDisplayTest {
+
+ @Test(groups = { "Functional" })
+ public void testDisplayColumnNames()
+ {
+ // 4 column names returned although 5 names internal to UrlLinkDisplay
+ List<String> names = UrlLinkDisplay.getDisplayColumnNames();
+ Assert.assertEquals(names.size(), 4);
+ }
+
+ @Test(groups = { "Functional" })
+ public void getValue()
+ {
+ UrlLink link = new UrlLink("Test Url",
+ "http://identifiers.org/$DB_ACCESSION$");
+ UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
+
+ Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.DEFAULT));
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "Test");
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "Test Url");
+ Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.SELECTED));
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
+ "http://identifiers.org/$DB_ACCESSION$");
+ }
+
+ @Test(groups = { "Functional" })
+ public void testIsEditable()
+ {
+ // only default and selected columns are editable ever
+ // default only editable if link contains $SEQUENCE_ID$
+
+ UrlLink link = new UrlLink("Test Url",
+ "http://identifiers.org/$DB_ACCESSION$");
+ UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
+
+ Assert.assertFalse(u.isEditable(UrlLinkDisplay.DEFAULT));
+ Assert.assertTrue(u.isEditable(UrlLinkDisplay.SELECTED));
+ Assert.assertFalse(u.isEditable(UrlLinkDisplay.ID));
+ Assert.assertFalse(u.isEditable(UrlLinkDisplay.URL));
+ Assert.assertFalse(u.isEditable(UrlLinkDisplay.NAME));
+
+ UrlLink vlink = new UrlLink("Test Sequence ID Url",
+ "http://myurl/$SEQUENCE_ID$");
+ UrlLinkDisplay v = new UrlLinkDisplay("Test", vlink, false, false);
+
+ Assert.assertTrue(v.isEditable(UrlLinkDisplay.DEFAULT));
+ Assert.assertTrue(v.isEditable(UrlLinkDisplay.SELECTED));
+ Assert.assertFalse(v.isEditable(UrlLinkDisplay.ID));
+ Assert.assertFalse(v.isEditable(UrlLinkDisplay.URL));
+ Assert.assertFalse(v.isEditable(UrlLinkDisplay.NAME));
+ }
+
+ @Test(groups = { "Functional" })
+ public void testName()
+ {
+ UrlLink link = new UrlLink("Test Url",
+ "http://identifiers.org/$DB_ACCESSION$");
+ UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
+
+ // Name initially as input in link
+ Assert.assertEquals(u.getName(), "Test Url");
+
+ // Setting updates name
+ u.setName("New Name");
+ Assert.assertEquals(u.getName(), "New Name");
+ }
+
+ @Test(groups = { "Functional" })
+ public void testUrl()
+ {
+ UrlLink link = new UrlLink("Test Url",
+ "http://identifiers.org/$DB_ACCESSION$");
+ UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
+
+ // Url initially as input in link
+ Assert.assertEquals(u.getUrl(), "http://identifiers.org/$DB_ACCESSION$");
+
+ // Setting updates url
+ u.setUrl("http://something.new/$SEQUENCE_ID$");
+ Assert.assertEquals(u.getUrl(), "http://something.new/$SEQUENCE_ID$");
+ }
+
+ @Test(groups = { "Functional" })
+ public void testGetSetValue()
+ {
+ UrlLink link = new UrlLink("Test Url",
+ "http://identifiers.org/$DB_ACCESSION$");
+ UrlLinkDisplay u = new UrlLinkDisplay("Test", link, false, false);
+
+ Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.DEFAULT));
+ Assert.assertFalse((boolean) u.getValue(UrlLinkDisplay.SELECTED));
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "Test Url");
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "Test");
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
+ "http://identifiers.org/$DB_ACCESSION$");
+
+ u.setValue(UrlLinkDisplay.DEFAULT, true);
+ Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.DEFAULT));
+
+ u.setValue(UrlLinkDisplay.SELECTED, true);
+ Assert.assertTrue((boolean) u.getValue(UrlLinkDisplay.SELECTED));
+
+ u.setValue(UrlLinkDisplay.NAME, "New Name");
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.NAME), "New Name");
+
+ u.setValue(UrlLinkDisplay.ID, "New ID");
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.ID), "New ID");
+
+ u.setValue(UrlLinkDisplay.URL, "http://something.new/$SEQUENCE_ID$");
+ Assert.assertEquals(u.getValue(UrlLinkDisplay.URL),
+ "http://something.new/$SEQUENCE_ID$");
+ }
+}