2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
23 import static org.testng.AssertJUnit.assertEquals;
25 import jalview.gui.JvOptionPane;
27 import org.testng.Assert;
28 import org.testng.annotations.BeforeClass;
29 import org.testng.annotations.Test;
34 @BeforeClass(alwaysRun = true)
35 public void setUpJvOptionPane()
37 JvOptionPane.setInteractiveMode(false);
38 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
42 * Test the constructor that parses a PDB file format ATOM line. Fields are in
43 * fixed column positions
45 @Test(groups = { "Functional" })
46 public void testStringConstructor()
49 "ATOM 349 NE2 GLN A 48 22.290 8.595 17.680 1.00 14.30 N");
50 assertEquals(349, a.atomIndex);
51 assertEquals("NE", a.name);
52 assertEquals("GLN", a.resName);
53 assertEquals("A", a.chain);
54 assertEquals(48, a.resNumber);
55 assertEquals("48", a.resNumIns);
56 assertEquals(' ', a.insCode);
57 assertEquals(22.290, a.x, 0.00001);
58 assertEquals(8.595, a.y, 0.00001);
59 assertEquals(17.680, a.z, 0.00001);
60 assertEquals(1f, a.occupancy, 0.00001);
61 assertEquals(14.3, a.tfactor, 0.00001);
65 * Test the case where occupancy and temp factor are blank - should default to
68 @Test(groups = { "Functional" })
69 public void testStringConstructor_blankOccupancyTempFactor()
72 "ATOM 349 NE2 GLN A 48 22.290 8.595 17.680 N");
73 assertEquals(1f, a.occupancy, 0.00001);
74 assertEquals(1f, a.tfactor, 0.00001);
78 * Parsing non-numeric data as Atom throws an exception
80 @Test(groups = { "Functional" })
81 public void testStringConstructor_malformed()
86 "ATOM 34N NE2 GLN A 48 22.290 8.595 17.680 1.00 14.30 N");
87 Assert.fail("Expected exception");
88 } catch (NumberFormatException e)