1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.urls; |
22 |
|
|
23 |
|
import jalview.urls.api.UrlProviderFactoryI; |
24 |
|
import jalview.urls.api.UrlProviderI; |
25 |
|
import jalview.urls.applet.AppletUrlProviderFactory; |
26 |
|
import jalview.util.UrlConstants; |
27 |
|
|
28 |
|
import java.util.HashMap; |
29 |
|
import java.util.List; |
30 |
|
import java.util.Map; |
31 |
|
|
32 |
|
import org.testng.Assert; |
33 |
|
import org.testng.annotations.Test; |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 2 |
Complexity Density: 0.1 |
|
35 |
|
public class AppletUrlProviderFactoryTest |
36 |
|
{ |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
38 |
1 |
@Test(groups = { "Functional" })... |
39 |
|
public void testCreateUrlProvider() |
40 |
|
{ |
41 |
1 |
final String defaultUrl = UrlConstants.DEFAULT_STRING.substring( |
42 |
|
UrlConstants.DEFAULT_STRING.indexOf(UrlConstants.SEP) + 1, |
43 |
|
UrlConstants.DEFAULT_STRING.length()); |
44 |
1 |
Map<String, String> urlList = new HashMap<String, String>() |
45 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
46 |
1 |
{... |
47 |
1 |
put("Test1", "http://identifiers.org/uniprot/$DB_ACCESSION$"); |
48 |
1 |
put("Test2", defaultUrl); |
49 |
|
} |
50 |
|
}; |
51 |
|
|
52 |
1 |
UrlProviderFactoryI factory = new AppletUrlProviderFactory("Test2", |
53 |
|
urlList); |
54 |
1 |
UrlProviderI prov = factory.createUrlProvider(); |
55 |
|
|
56 |
|
|
57 |
1 |
Assert.assertEquals(prov.getPrimaryUrlId(), "Test2"); |
58 |
1 |
Assert.assertEquals(prov.getPrimaryUrl("FER_CAPAN"), |
59 |
|
defaultUrl.replace("$SEQUENCE_ID$", "FER_CAPAN")); |
60 |
|
|
61 |
1 |
List<UrlLinkDisplay> allLinks = prov.getLinksForTable(); |
62 |
|
|
63 |
|
|
64 |
1 |
Assert.assertEquals(allLinks.size(), 2); |
65 |
|
|
66 |
|
|
67 |
1 |
Assert.assertEquals(allLinks.get(0).getId(), "Test1"); |
68 |
1 |
Assert.assertEquals(allLinks.get(0).getDescription(), "Test1"); |
69 |
1 |
Assert.assertEquals(allLinks.get(0).getUrl(), |
70 |
|
"http://identifiers.org/uniprot/$DB_ACCESSION$"); |
71 |
1 |
Assert.assertFalse(allLinks.get(0).getIsPrimary()); |
72 |
1 |
Assert.assertTrue(allLinks.get(0).getIsSelected()); |
73 |
|
|
74 |
|
|
75 |
1 |
Assert.assertEquals(allLinks.get(1).getId(), "Test2"); |
76 |
1 |
Assert.assertEquals(allLinks.get(1).getDescription(), "Test2"); |
77 |
1 |
Assert.assertEquals(allLinks.get(1).getUrl(), defaultUrl); |
78 |
1 |
Assert.assertTrue(allLinks.get(1).getIsPrimary()); |
79 |
1 |
Assert.assertTrue(allLinks.get(1).getIsSelected()); |
80 |
|
} |
81 |
|
} |