X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FPDBEntryTest.java;h=80b7376644f5f6e3e15b439507261f30c7fc1801;hb=584ab9644955bec02d96448361b8aac5b9542599;hp=979fee4632759fde6b2f33e047753f33f385c15f;hpb=b9012154b256ce7dc7125072706e918ab97ffe87;p=jalview.git diff --git a/test/jalview/datamodel/PDBEntryTest.java b/test/jalview/datamodel/PDBEntryTest.java index 979fee4..80b7376 100644 --- a/test/jalview/datamodel/PDBEntryTest.java +++ b/test/jalview/datamodel/PDBEntryTest.java @@ -31,17 +31,24 @@ import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import jalview.datamodel.PDBEntry.Type; - -import java.util.Hashtable; +import jalview.gui.JvOptionPane; //import org.testng.Assert; import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class PDBEntryTest { + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + @BeforeMethod(alwaysRun = true) public void setUp() throws Exception { @@ -83,7 +90,7 @@ public class PDBEntryTest PDBEntry case9 = new PDBEntry("1xyz", "A", null, "x/y/z/File"); // different file only PDBEntry case10 = new PDBEntry("1xyz", "A", null, "a/b/c/File"); - + /* * assertEquals will invoke PDBEntry.equals() */ @@ -101,17 +108,17 @@ public class PDBEntryTest assertNotEquals(case9, case10); // add properties - case7.getProperty().put("hello", "world"); + case7.setProperty("hello", "world"); assertNotEquals(case7, case9); - case9.getProperty().put("hello", "world"); + case9.setProperty("hello", "world"); assertEquals(case7, case9); - case9.getProperty().put("hello", "WORLD"); + case9.setProperty("hello", "WORLD"); assertNotEquals(case7, case9); /* * change string wrapper property to string... */ - case1.getProperty().put("chain_code", "a"); + case1.setProperty("chain_code", "a"); assertFalse(pdbEntry.equals(case1)); assertFalse(case1.equals(pdbEntry)); } @@ -201,7 +208,7 @@ public class PDBEntryTest assertTrue(pdb1.updateFrom(pdb2)); assertEquals(pdb1.getFile(), "filePath"); assertEquals(pdb1.getType(), Type.FILE.toString()); - + assertEquals(pdb1.getChainCode(),"B"); /* * change of file is not allowed */ @@ -245,28 +252,38 @@ public class PDBEntryTest */ pdb1 = new PDBEntry("3A6S", null, null, null); pdb2 = new PDBEntry("3A6S", null, null, null); - // ughh properties not null if chain code has been set... - // JAL-2196 addresses this - pdb1.properties = new Hashtable(); - pdb2.properties = new Hashtable(); - pdb1.properties.put("destination", "mars"); - pdb1.properties.put("hello", "world"); - pdb2.properties.put("hello", "moon"); - pdb2.properties.put("goodbye", "world"); + pdb1.setProperty("destination", "mars"); + pdb1.setProperty("hello", "world"); + pdb2.setProperty("hello", "moon"); + pdb2.setProperty("goodbye", "world"); assertTrue(pdb1.updateFrom(pdb2)); - assertEquals(pdb1.properties.get("destination"), "mars"); - assertEquals(pdb1.properties.get("hello"), "moon"); - assertEquals(pdb1.properties.get("goodbye"), "world"); + assertEquals(pdb1.getProperty("destination"), "mars"); + assertEquals(pdb1.getProperty("hello"), "moon"); + assertEquals(pdb1.getProperty("goodbye"), "world"); /* * add properties only */ pdb1 = new PDBEntry("3A6S", null, null, null); pdb2 = new PDBEntry("3A6S", null, null, null); - pdb2.properties = new Hashtable(); - pdb2.properties.put("hello", "moon"); + pdb2.setProperty("hello", "moon"); + assertTrue(pdb1.updateFrom(pdb2)); + assertEquals(pdb1.getProperty("hello"), "moon"); + + /* + * different id but authoritative + */ + pdb1 = new PDBEntry("af:1xyz", "A", null, "a/b/c/File"); + pdb2 = new PDBEntry("af-1xyz", "A", null, "a/b/c/File"); + pdb1.setAuthoritative(true); + + assertTrue(pdb1.isAuthoritative()); + assertFalse(pdb2.isAuthoritative()); + // can update pdb1 (authoritative) from pdb2 (non-authoritative) assertTrue(pdb1.updateFrom(pdb2)); - assertEquals(pdb1.properties.get("hello"), "moon"); + // but the ID must remain the same + assertEquals(pdb1.getId(),"af:1xyz"); + } @Test(groups = { "Functional" })