JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / test / jalview / datamodel / DBRefEntryTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
3  * Copyright (C) 2015 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.AssertJUnit.assertFalse;
24 import static org.testng.AssertJUnit.assertTrue;
25
26 import jalview.util.MapList;
27
28 import org.testng.annotations.Test;
29
30 public class DBRefEntryTest
31 {
32
33   /**
34    * Tests for the method that compares equality of reference (but not mapping)
35    */
36   @Test(groups = { "Functional" })
37   public void testEqualRef()
38   {
39     DBRefEntry ref1 = new DBRefEntry("UNIPROT", "1", "V71633");
40     assertTrue(ref1.equalRef(ref1));
41     assertFalse(ref1.equalRef(null));
42
43     // comparison is not case sensitive
44     DBRefEntry ref2 = new DBRefEntry("uniprot", "1", "v71633");
45     assertTrue(ref1.equalRef(ref2));
46     assertTrue(ref2.equalRef(ref1));
47
48     // source, version and accessionid must match
49     assertFalse(ref1.equalRef(new DBRefEntry("UNIPRO", "1", "V71633")));
50     assertFalse(ref1.equalRef(new DBRefEntry("UNIPROT", "2", "V71633")));
51     assertFalse(ref1.equalRef(new DBRefEntry("UNIPROT", "1", "V71632")));
52
53     // presence of or differences in mappings are ignored
54     ref1.setMap(new Mapping(new MapList(new int[] { 1, 3 }, new int[] { 1,
55         1 }, 3, 1)));
56     assertTrue(ref1.equalRef(ref2));
57     assertTrue(ref2.equalRef(ref1));
58     ref1.setMap(new Mapping(new MapList(new int[] { 1, 6 }, new int[] { 1,
59         2 }, 3, 1)));
60     assertTrue(ref1.equalRef(ref2));
61     assertTrue(ref2.equalRef(ref1));
62   }
63 }