X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FDBRefEntryTest.java;h=c8f998b247bc57a9f17d7f4d2e0e94f6d178b684;hb=be38fa8acaa8061b501a4e94fb7dea4b7ed8ed41;hp=09d9df1f0c2661d24c398507254d1a2ee3b947eb;hpb=9a0e53e18ba1280658e1424c5e08b90e7beeebde;p=jalview.git diff --git a/test/jalview/datamodel/DBRefEntryTest.java b/test/jalview/datamodel/DBRefEntryTest.java index 09d9df1..c8f998b 100644 --- a/test/jalview/datamodel/DBRefEntryTest.java +++ b/test/jalview/datamodel/DBRefEntryTest.java @@ -25,13 +25,22 @@ import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; +import jalview.gui.JvOptionPane; import jalview.util.MapList; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class DBRefEntryTest { + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + /** * Tests for the method that compares equality of reference (but not mapping) */ @@ -81,7 +90,7 @@ public class DBRefEntryTest assertTrue(ref1.updateFrom(ref2)); assertEquals("UNIPROT", ref1.getSource()); // unchanged assertEquals("V71633", ref1.getAccessionId()); // unchanged - + /* * ref1 has no mapping, acquires mapping from ref2 */ @@ -140,60 +149,80 @@ public class DBRefEntryTest } @Test(groups = { "Functional" }) - public void testIsPrimary() + public void testIsPrimaryCandidate() { DBRefEntry dbr = new DBRefEntry(DBRefSource.UNIPROT, "", "Q12345"); - assertTrue(dbr.isPrimary()); + assertTrue(dbr.isPrimaryCandidate()); + /* - * 1:1 mapping + * 1:1 mapping - ok */ dbr.setMap(new Mapping(null, new int[] { 1, 3 }, new int[] { 1, 3 }, 1, 1)); - assertTrue(dbr.isPrimary()); + assertTrue(dbr.isPrimaryCandidate()); + + /* + * 1:1 mapping of identical split ranges - not ok + */ + dbr.setMap(new Mapping(null, new int[] { 1, 3, 6, 9 }, new int[] { 1, + 3, 6, 9 }, 1, 1)); + assertFalse(dbr.isPrimaryCandidate()); + + /* + * 1:1 mapping of different ranges - not ok + */ + dbr.setMap(new Mapping(null, new int[] { 1, 4 }, new int[] { 2, 5 }, 1, + 1)); + assertFalse(dbr.isPrimaryCandidate()); + + /* + * 1:1 mapping of 'isoform' ranges - not ok + */ + dbr.setMap(new Mapping(null, new int[] { 1, 2, 6, 9 }, new int[] { 1, + 3, 7, 9 }, 1, 1)); + assertFalse(dbr.isPrimaryCandidate()); + dbr.setMap(null); + assertTrue(dbr.isPrimaryCandidate()); + /* * Version string is prefixed with another dbref source string (fail) */ dbr.setVersion(DBRefSource.EMBL + ":0"); - assertFalse(dbr.isPrimary()); + assertFalse(dbr.isPrimaryCandidate()); /* * Version string is alphanumeric */ dbr.setVersion("0.1.b"); - assertTrue(dbr.isPrimary()); + assertTrue(dbr.isPrimaryCandidate()); /* - * 1:1 mapping with shift (fail) + * null version string can't be primary ref */ - dbr.setMap(new Mapping(null, new int[] { 1, 3 }, new int[] { 2, 4 }, 1, - 1)); - assertFalse(dbr.isPrimary()); + dbr.setVersion(null); + assertFalse(dbr.isPrimaryCandidate()); + dbr.setVersion(""); + assertTrue(dbr.isPrimaryCandidate()); /* * 1:1 mapping and sequenceRef (fail) */ dbr.setMap(new Mapping(new Sequence("foo", "ASDF"), new int[] { 1, 3 }, new int[] { 1, 3 }, 1, 1)); - assertFalse(dbr.isPrimary()); + assertFalse(dbr.isPrimaryCandidate()); /* * 1:3 mapping (fail) */ dbr.setMap(new Mapping(null, new int[] { 1, 3 }, new int[] { 1, 3 }, 1, 3)); - assertFalse(dbr.isPrimary()); + assertFalse(dbr.isPrimaryCandidate()); + /* * 2:2 mapping with shift (expected fail, but maybe use case for a pass) */ - dbr.setMap(new Mapping(null, new int[] { 1, 3 }, new int[] { 1, 3 }, 2, + dbr.setMap(new Mapping(null, new int[] { 1, 4 }, new int[] { 1, 4 }, 2, 2)); - assertFalse(dbr.isPrimary()); - - /* - * Version string is prefixed with another dbref source string - */ - dbr.setVersion(DBRefSource.EMBL + ":0"); - assertFalse(dbr.isPrimary()); - + assertFalse(dbr.isPrimaryCandidate()); } }