From: Jim Procter Date: Wed, 26 Jun 2019 16:36:58 +0000 (+0100) Subject: JAL-3332 test to check for duplicate db sources and patch to code. crept in after... X-Git-Tag: Release_2_11_0~4^2~1^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e7e569d85f161d6f508851d861ab3e76e2b4bbf9;p=jalview.git JAL-3332 test to check for duplicate db sources and patch to code. crept in after das source removal --- diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index a28be2c..d3aeead 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -97,8 +97,8 @@ public class SequenceFetcher extends ASequenceFetcher int i = 0; for (int j = sorted.length - 1; j >= 0; j--, i++) { - srcs[i] = sorted[j]; + tosort[i] = sorted[j]; } - return srcs; + return tosort; } } diff --git a/test/jalview/ws/SequenceFetcherTest.java b/test/jalview/ws/SequenceFetcherTest.java index 0b501ee..70c6266 100644 --- a/test/jalview/ws/SequenceFetcherTest.java +++ b/test/jalview/ws/SequenceFetcherTest.java @@ -30,10 +30,14 @@ import jalview.ws.seqfetcher.ASequenceFetcher; import jalview.ws.seqfetcher.DbSourceProxy; import java.util.Enumeration; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Vector; +import org.testng.Assert; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; public class SequenceFetcherTest { @@ -45,6 +49,30 @@ public class SequenceFetcherTest JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); } + @Test(groups = "Functional") + public void testNoDuplicatesInFetchDbRefs() + { + Map> seen = new HashMap<>(); + jalview.ws.SequenceFetcher sfetcher = new jalview.ws.SequenceFetcher(); + String dupes = ""; + for (String src : sfetcher.getOrderedSupportedSources()) + { + List seenitem = seen.get(src); + if (seenitem != null) + { + dupes += (dupes.length() > 0 ? "," : "") + src; + } + else + { + seen.put(src, sfetcher.getSourceProxy(src)); + } + } + if (dupes.length() > 0) + { + Assert.fail("Duplicate sources : " + dupes); + } + } + /** * simple run method to test dbsources. *