--- /dev/null
+package jalview.analysis;
+
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+
+import java.util.Arrays;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class SequenceIdMatcherTest
+{
+ private static SequenceI[] someseqs = {
+ new Sequence("A|ComplexId", "dummy"),
+ new Sequence("A|ComplexId|confused", "dummy"),
+ new Sequence("A|ComplexId|bits_of", "dummy"),
+ new Sequence("ComplexId", "dummy"),
+ new Sequence("A|ComplexIdNot", "dummy"),
+ new Sequence("A ComplexId Id", "dummy"),
+ new Sequence("complexid", "dummy") };
+
+ private static SequenceIdMatcher getMatcher()
+ {
+ return new SequenceIdMatcher(Arrays.asList(someseqs));
+ }
+
+ @Test(groups = { "Functional" })
+ public void findSelfAndOthers()
+ {
+ for (SequenceI sq : SequenceIdMatcherTest.someseqs)
+ {
+ SequenceI[] idmatches = getMatcher().findAllIdMatches(sq.getName());
+ Assert.assertTrue(
+ idmatches.length >= 1,
+ "Couldn't recover at least one sequence for string '"
+ + sq.getName() + "'");
+ SequenceI[] seqmatches = getMatcher().findIdMatch(
+ new SequenceI[] { sq });
+ Assert.assertTrue(seqmatches.length >= 1,
+ "Couldn't recover at least one sequence for sequence object called '"
+ + sq.getName() + "'");
+ Assert.assertTrue(seqmatches.length == idmatches.length,
+ "Different matches found for '" + sq.getName() + "'");
+ for (SequenceI sid : idmatches)
+ {
+ boolean found = false;
+ for (SequenceI sobj : seqmatches)
+ {
+ if (sid == sobj)
+ {
+ found = true;
+ }
+ }
+ Assert.assertTrue(
+ found,
+ "Different sequences recovered for Id "
+ + "and SequenceI (Couldn't find match for '"
+ + sid.getName() + "')");
+
+ }
+ }
+ }
+
+ @Test(groups = { "Functional" })
+ public void testExactMatch()
+ {
+ SequenceI[] matches = getMatcher().findAllIdMatches("A|ComplexId");
+ Assert.assertTrue(matches.length == 1,
+ "Exact match failed for 'A|ComplexId'");
+ matches = getMatcher().findAllIdMatches("A|ComplexId|confused");
+ Assert.assertTrue(matches.length == 1,
+ "Exact match failed for 'A|ComplexId|confused'");
+ matches = getMatcher().findAllIdMatches("A|ComplexId|bits_of");
+ Assert.assertTrue(matches.length == 1,
+ "Exact match failed for 'A|ComplexId|bits_of'");
+ matches = getMatcher().findAllIdMatches("A ComplexId Id");
+ Assert.assertTrue(matches.length == 1,
+ "Exact match failed for 'A Complex Id'");
+
+ }
+
+ public void testContainedMatch()
+ {
+
+ }
+}