import jalview.gui.JvOptionPane;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
UrlLink ul = new UrlLink(DB + SEP + URL_PREFIX + DELIM + SEQUENCE_ID
+ DELIM + URL_SUFFIX);
- Map<String, List<String>> linkset = new LinkedHashMap<String, List<String>>();
+ Map<String, List<String>> linkset = new LinkedHashMap<>();
ul.createLinksFromSeq(null, linkset);
String key = DB + SEP + URL_PREFIX;
{
UrlLink ul = new UrlLink(DB + SEP + URL_PREFIX + URL_SUFFIX);
- Map<String, List<String>> linkset = new LinkedHashMap<String, List<String>>();
+ Map<String, List<String>> linkset = new LinkedHashMap<>();
ul.createLinksFromSeq(null, linkset);
String key = DB + SEP + URL_PREFIX + URL_SUFFIX;
{
// create list of links and list of DBRefs
- List<String> links = new ArrayList<String>();
- List<DBRefEntry> refs = new ArrayList<DBRefEntry>();
+ List<String> links = new ArrayList<>();
+ List<DBRefEntry> refs = new ArrayList<>();
// links as might be added into Preferences | Connections dialog
links.add("EMBL-EBI Search | http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$"
UrlLink ul = new UrlLink(DB + SEP + URL_PREFIX + DELIM + SEQUENCE_ID
+ DELIM + URL_SUFFIX);
- Map<String, List<String>> linkset = new LinkedHashMap<String, List<String>>();
+ Map<String, List<String>> linkset = new LinkedHashMap<>();
ul.createLinksFromSeq(seq0, linkset);
String key = seq0.getName() + SEP + URL_PREFIX + seq0.getName()
// Test where link takes a db annotation id and only has one dbref
ul = new UrlLink(links.get(1));
- linkset = new LinkedHashMap<String, List<String>>();
+ linkset = new LinkedHashMap<>();
ul.createLinksFromSeq(seq0, linkset);
key = "P83527|http://www.uniprot.org/uniprot/P83527";
// Test where link takes a db annotation id and has multiple dbrefs
ul = new UrlLink(links.get(2));
- linkset = new LinkedHashMap<String, List<String>>();
+ linkset = new LinkedHashMap<>();
ul.createLinksFromSeq(seq0, linkset);
assertEquals(3, linkset.size());
// Test where there are no matching dbrefs for the link
ul = new UrlLink(DB + SEP + URL_PREFIX + DELIM + DB_ACCESSION + DELIM
+ URL_SUFFIX);
- linkset = new LinkedHashMap<String, List<String>>();
+ linkset = new LinkedHashMap<>();
ul.createLinksFromSeq(seq0, linkset);
assertTrue(linkset.isEmpty());
}
}
+ @Test(groups = { "Functional" })
+ public void testLinkComparator()
+ {
+ Comparator<String> c = UrlLink.LINK_COMPARATOR;
+ assertEquals(0, c.compare(null, null));
+ assertEquals(0, c.compare(null, "x"));
+ assertEquals(0, c.compare("y", null));
+
+ /*
+ * SEQUENCE_ID templates should come before DB_ACCESSION templates
+ */
+ String dbRefUrl = "Cath|http://www.cathdb.info/version/v4_2_0/superfamily/$DB_ACCESSION$";
+ String seqIdUrl = "EBI|https://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$";
+ assertTrue(c.compare(seqIdUrl, dbRefUrl) < 0);
+ assertTrue(c.compare(dbRefUrl, seqIdUrl) > 0);
+
+ String interpro = "Interpro|https://www.ebi.ac.uk/interpro/entry/$DB_ACCESSION$";
+ String prosite = "ProSite|https://prosite.expasy.org/PS00197";
+ assertTrue(c.compare(interpro, prosite) < 0);
+ assertTrue(c.compare(prosite, interpro) > 0);
+ }
}