X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Furls%2FAppletUrlProviderFactoryTest.java;fp=test%2Fjalview%2Furls%2FAppletUrlProviderFactoryTest.java;h=2a967e4589f1fae53961b713901eeb586a19fef4;hb=2595e9d4ee0dbbd3406a98c4e49a61ccde806479;hp=0000000000000000000000000000000000000000;hpb=e20075ba805d744d7cc4976e2b8d5e5840fb0a8d;p=jalview.git diff --git a/test/jalview/urls/AppletUrlProviderFactoryTest.java b/test/jalview/urls/AppletUrlProviderFactoryTest.java new file mode 100644 index 0000000..2a967e4 --- /dev/null +++ b/test/jalview/urls/AppletUrlProviderFactoryTest.java @@ -0,0 +1,81 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.urls; + +import jalview.urls.api.UrlProviderFactoryI; +import jalview.urls.api.UrlProviderI; +import jalview.urls.applet.AppletUrlProviderFactory; +import jalview.util.UrlConstants; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class AppletUrlProviderFactoryTest { + + @Test(groups = { "Functional" }) + public void testCreateUrlProvider() + { + final String defaultUrl = UrlConstants.DEFAULT_STRING.substring( + UrlConstants.DEFAULT_STRING.indexOf(UrlConstants.SEP) + 1, + UrlConstants.DEFAULT_STRING.length()); + Map urlList = new HashMap() + { + { + put("Test1", "http://identifiers.org/uniprot/$DB_ACCESSION$"); + put("Test2", defaultUrl); + } + }; + + UrlProviderFactoryI factory = new AppletUrlProviderFactory("Test2", + urlList); + UrlProviderI prov = factory.createUrlProvider(); + + // default url correctly set + Assert.assertEquals(prov.getPrimaryUrlId(), "Test2"); + Assert.assertEquals(prov.getPrimaryUrl("FER_CAPAN"), + defaultUrl.replace("$SEQUENCE_ID$", + "FER_CAPAN")); + + List allLinks = prov.getLinksForTable(); + + // 2 links in provider + Assert.assertEquals(allLinks.size(), 2); + + // first link set correctly + Assert.assertEquals(allLinks.get(0).getId(), "Test1"); + Assert.assertEquals(allLinks.get(0).getDescription(), "Test1"); + Assert.assertEquals(allLinks.get(0).getUrl(), + "http://identifiers.org/uniprot/$DB_ACCESSION$"); + Assert.assertFalse(allLinks.get(0).getIsPrimary()); + Assert.assertTrue(allLinks.get(0).getIsSelected()); + + // second link set correctly + Assert.assertEquals(allLinks.get(1).getId(), "Test2"); + Assert.assertEquals(allLinks.get(1).getDescription(), "Test2"); + Assert.assertEquals(allLinks.get(1).getUrl(), defaultUrl); + Assert.assertTrue(allLinks.get(1).getIsPrimary()); + Assert.assertTrue(allLinks.get(1).getIsSelected()); + } +}