git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-4235 JAL-3599 Try and report Eclipse Product Version for jalviewjsTranspile....
[jalview.git]
/
test
/
jalview
/
urls
/
CustomUrlProviderTest.java
diff --git
a/test/jalview/urls/CustomUrlProviderTest.java
b/test/jalview/urls/CustomUrlProviderTest.java
index
62d7806
..
58b2731
100644
(file)
--- a/
test/jalview/urls/CustomUrlProviderTest.java
+++ b/
test/jalview/urls/CustomUrlProviderTest.java
@@
-24,6
+24,9
@@
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.urls.api.UrlProviderI;
+import jalview.util.UrlConstants;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.Vector;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Vector;
@@
-38,26
+41,43
@@
public class CustomUrlProviderTest
+ "TEST2|http://address/$SEQUENCE_ID$|SRS|"
+ "http://theSRSlink/$SEQUENCE_ID$";
+ "TEST2|http://address/$SEQUENCE_ID$|SRS|"
+ "http://theSRSlink/$SEQUENCE_ID$";
+ private static final String unselectedList = "NON1|http://x/y/$DB_ACCESSION$|"
+ + "NON2|http://a/b/c/$DB_ACCESSION";
+
private static final HashMap<String, String> urlMap = new HashMap<String, String>()
{
{
private static final HashMap<String, String> urlMap = new HashMap<String, String>()
{
{
- put("TEST","http://someurl.blah/$DB_ACCESSION$");
- put("ANOTHER","http://test/t$SEQUENCE_ID$");
+ put("TEST", "http://someurl.blah/$DB_ACCESSION$");
+ put("ANOTHER", "http://test/t$SEQUENCE_ID$");
put("TEST2", "http://address/$SEQUENCE_ID$");
put("SRS", "http://theSRSlink/$SEQUENCE_ID$");
}
};
put("TEST2", "http://address/$SEQUENCE_ID$");
put("SRS", "http://theSRSlink/$SEQUENCE_ID$");
}
};
-
+
+ private static final HashMap<String, String> unselUrlMap = new HashMap<String, String>()
+ {
+ {
+ put("NON1", "http://x/y/$DB_ACCESSION$");
+ put("NON2", "http://a/b/c/$DB_ACCESSION");
+ }
+ };
+
private static final String[] dlinks = {
"TEST|http://someurl.blah/$DB_ACCESSION$",
"ANOTHER|http://test/t$SEQUENCE_ID$",
private static final String[] dlinks = {
"TEST|http://someurl.blah/$DB_ACCESSION$",
"ANOTHER|http://test/t$SEQUENCE_ID$",
- "TEST2|http://address/$SEQUENCE_ID$",
- UrlProviderI.DEFAULT_STRING };
+ "TEST2|http://address/$SEQUENCE_ID$", UrlConstants.DEFAULT_STRING };
+
+ private static final String[] unselDlinks = {
+ "NON1|http://x/y/$DB_ACCESSION$", "NON2|http://a/b/c/$DB_ACCESSION" };
private static final Vector<String> displayLinks = new Vector<String>(
Arrays.asList(dlinks));
private static final Vector<String> displayLinks = new Vector<String>(
Arrays.asList(dlinks));
- private static final String[] dlinks2 = { "a|http://x.y.z/$SEQUENCE_ID$" };
+ private static final Vector<String> unselDisplayLinks = new Vector<String>(
+ Arrays.asList(unselDlinks));
+
+ private static final String[] dlinks2 = {
+ "a|http://x.y.z/$SEQUENCE_ID$" };
private static final Vector<String> displayLinks2 = new Vector<String>(
Arrays.asList(dlinks2));
private static final Vector<String> displayLinks2 = new Vector<String>(
Arrays.asList(dlinks2));
@@
-78,29
+98,30
@@
public class CustomUrlProviderTest
@Test(groups = { "Functional" })
public void testDefaultUrl()
{
@Test(groups = { "Functional" })
public void testDefaultUrl()
{
- UrlProviderI customProv = new CustomUrlProvider(cachedList);
-
+ UrlProviderI customProv = new CustomUrlProvider(cachedList,
+ unselectedList);
+
// default url can be set
// default url can be set
- assertTrue(customProv.setDefaultUrl("ANOTHER"));
- String result = customProv.getDefaultUrl();
- assertEquals("ANOTHER", result);
+ assertTrue(customProv.setPrimaryUrl("ANOTHER"));
+
+ // supplied replacement id must be more than 4 chars
+ String result = customProv.getPrimaryUrl("123");
+ assertEquals(null, result);
// default url can be retrieved given a sequence id
// default url can be retrieved given a sequence id
- result = customProv.getDefaultUrl("seqid");
+ result = customProv.getPrimaryUrl("seqid");
assertEquals("http://test/tseqid", result);
// if there is no default url it sets the default to null
assertEquals("http://test/tseqid", result);
// if there is no default url it sets the default to null
- assertFalse(customProv.setDefaultUrl("No default"));
- result = customProv.getDefaultUrl();
+ assertFalse(customProv.setPrimaryUrl("No default"));
+ result = customProv.getPrimaryUrl("testid");
assertEquals(null, result);
assertEquals(null, result);
-
+
// choosing the default picks the DEFAULT_STRING option
// choosing the default picks the DEFAULT_STRING option
- customProv.chooseDefaultUrl();
- result = customProv.getDefaultUrl("seqid");
- assertEquals(
- UrlProviderI.DEFAULT_STRING.split("\\|")[1].split("\\$")[0]
- + "seqid",
- result);
+ customProv.choosePrimaryUrl();
+ result = customProv.getPrimaryUrl("seqid");
+ assertEquals(UrlConstants.DEFAULT_STRING.split("\\|")[1].split("\\$")[0]
+ + "seqid", result);
}
/*
}
/*
@@
-110,29
+131,31
@@
public class CustomUrlProviderTest
public void testUrlLinks()
{
// creation from cached url list works + old links upgraded
public void testUrlLinks()
{
// creation from cached url list works + old links upgraded
- UrlProviderI customProv = new CustomUrlProvider(cachedList);
- assertTrue(displayLinks.containsAll(customProv.getLinksForDisplay()));
+ UrlProviderI customProv = new CustomUrlProvider(cachedList,
+ unselectedList);
+ assertTrue(displayLinks.containsAll(customProv.getLinksForMenu()));
// creation from map works + old links upgraded
// creation from map works + old links upgraded
- UrlProviderI customProv2 = new CustomUrlProvider(urlMap);
- assertTrue(displayLinks.containsAll(customProv2.getLinksForDisplay()));
+ UrlProviderI customProv2 = new CustomUrlProvider(urlMap, unselUrlMap);
+ assertTrue(displayLinks.containsAll(customProv2.getLinksForMenu()));
// writing url links as a string works
// because UrlProvider does not guarantee order of links, we can't just
// compare the output of writeUrlsAsString to a string, hence the hoops here
// writing url links as a string works
// because UrlProvider does not guarantee order of links, we can't just
// compare the output of writeUrlsAsString to a string, hence the hoops here
- String result = customProv.writeUrlsAsString();
- UrlProviderI up = new CustomUrlProvider(result);
- assertTrue(displayLinks.containsAll(up.getLinksForDisplay()));
+ String result = customProv.writeUrlsAsString(true);
+ UrlProviderI up = new CustomUrlProvider(result, "");
+ assertTrue(displayLinks.containsAll(up.getLinksForMenu()));
- result = customProv2.writeUrlsAsString();
- UrlProviderI up2 = new CustomUrlProvider(result);
- assertTrue(displayLinks.containsAll(up2.getLinksForDisplay()));
+ result = customProv.writeUrlsAsString(false);
+ up = new CustomUrlProvider("", result);
+ assertTrue(unselDisplayLinks.containsAll(up.getLinksForMenu()));
- // resetting urls from a pair of lists works
- customProv.setUrlLinks(names, urls);
- assertTrue(displayLinks2.containsAll(customProv.getLinksForDisplay()));
+ result = customProv2.writeUrlsAsString(true);
+ UrlProviderI up2 = new CustomUrlProvider(result, "");
+ assertTrue(displayLinks.containsAll(up2.getLinksForMenu()));
- customProv2.setUrlLinks(names, urls);
- assertTrue(displayLinks2.containsAll(customProv2.getLinksForDisplay()));
+ result = customProv2.writeUrlsAsString(false);
+ up2 = new CustomUrlProvider("", result);
+ assertTrue(displayLinks.containsAll(up2.getLinksForMenu()));
}
}
}
}