JAL-1803 extracted class ChainId to jalview.util.CaseInsensitiveString,
[jalview.git] / test / jalview / datamodel / PDBEntryTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.datamodel;
22
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertFalse;
25 import static org.testng.Assert.assertNotEquals;
26 import static org.testng.Assert.assertNull;
27
28 //import org.testng.Assert;
29 import org.testng.annotations.AfterMethod;
30 import org.testng.annotations.BeforeMethod;
31 import org.testng.annotations.Test;
32
33 public class PDBEntryTest
34 {
35
36   @BeforeMethod(alwaysRun = true)
37   public void setUp() throws Exception
38   {
39   }
40
41   @AfterMethod(alwaysRun = true)
42   public void tearDown() throws Exception
43   {
44   }
45
46   @Test(groups = { "Functional" })
47   public void testEquals()
48   {
49     PDBEntry pdbEntry = new PDBEntry("1xyz", "A", PDBEntry.Type.PDB,
50             "x/y/z/File");
51
52     PDBEntry case1 = new PDBEntry("1XYZ", "A", PDBEntry.Type.PDB,
53             "x/y/z/File");
54     PDBEntry case2 = new PDBEntry("1xyz", "a", PDBEntry.Type.PDB,
55             "x/y/z/File");
56     PDBEntry case3 = new PDBEntry("1xyz", "A", PDBEntry.Type.FILE,
57             "x/y/z/File");
58     PDBEntry case4 = new PDBEntry(null, null, null, null);
59     PDBEntry case5 = new PDBEntry(null, "A", PDBEntry.Type.PDB,
60             "x/y/z/File");
61     PDBEntry case6 = new PDBEntry("1xyz", null, PDBEntry.Type.PDB,
62             "x/y/z/File");
63     PDBEntry case7 = new PDBEntry("1xyz", "A", null, "x/y/z/File");
64     PDBEntry case8 = new PDBEntry("1xyz", "A", PDBEntry.Type.PDB, null);
65     PDBEntry case9 = new PDBEntry("1xyz", "A", null, "x/y/z/File");
66
67     /*
68      * assertions will invoke PDBEntry.equals()
69      */
70     assertFalse(pdbEntry.equals(null));
71     assertFalse(pdbEntry.equals("a"));
72     assertEquals(case1, pdbEntry);
73     assertEquals(case2, pdbEntry);
74     assertNotEquals(case3, pdbEntry);
75     assertNotEquals(case4, pdbEntry);
76     assertNotEquals(case5, pdbEntry);
77     assertNotEquals(case6, pdbEntry);
78     assertNotEquals(case7, pdbEntry);
79     assertEquals(case8, pdbEntry);
80     assertEquals(case7, case9);
81
82     /*
83      * change string wrapper property to string...
84      */
85     case1.getProperty().put("chain_code", "a");
86     assertFalse(pdbEntry.equals(case1));
87     assertFalse(case1.equals(pdbEntry));
88   }
89
90   @Test(groups = { "Functional" })
91   public void testSetChainCode()
92   {
93     PDBEntry pdbEntry = new PDBEntry("1xyz", null, PDBEntry.Type.PDB,
94             "x/y/z/File");
95     assertNull(pdbEntry.getChainCode());
96
97     pdbEntry.setChainCode("a");
98     assertEquals("a", pdbEntry.getChainCode());
99
100     pdbEntry.setChainCode(null);
101     assertNull(pdbEntry.getChainCode());
102   }
103 }