Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 20:42:03 GMT
  2. Package mc_view

File AtomTest.java

 

Code metrics

0
21
4
1
93
53
5
0.24
5.25
4
1.25

Classes

Class Line # Actions
AtomTest 31 21 5
0.9696%
 

Contributing tests

This file is covered by 3 tests. .

Source view

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 mc_view;
22   
23    import static org.testng.AssertJUnit.assertEquals;
24   
25    import jalview.gui.JvOptionPane;
26   
27    import org.testng.Assert;
28    import org.testng.annotations.BeforeClass;
29    import org.testng.annotations.Test;
30   
 
31    public class AtomTest
32    {
33   
 
34  1 toggle @BeforeClass(alwaysRun = true)
35    public void setUpJvOptionPane()
36    {
37  1 JvOptionPane.setInteractiveMode(false);
38  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
39    }
40   
41    /**
42    * Test the constructor that parses a PDB file format ATOM line. Fields are in
43    * fixed column positions
44    */
 
45  1 toggle @Test(groups = { "Functional" })
46    public void testStringConstructor()
47    {
48  1 Atom a = new Atom(
49    "ATOM 349 NE2 GLN A 48 22.290 8.595 17.680 1.00 14.30 N");
50  1 assertEquals(349, a.atomIndex);
51  1 assertEquals("NE", a.name);
52  1 assertEquals("GLN", a.resName);
53  1 assertEquals("A", a.chain);
54  1 assertEquals(48, a.resNumber);
55  1 assertEquals("48", a.resNumIns);
56  1 assertEquals(' ', a.insCode);
57  1 assertEquals(22.290, a.x, 0.00001);
58  1 assertEquals(8.595, a.y, 0.00001);
59  1 assertEquals(17.680, a.z, 0.00001);
60  1 assertEquals(1f, a.occupancy, 0.00001);
61  1 assertEquals(14.3, a.tfactor, 0.00001);
62    }
63   
64    /**
65    * Test the case where occupancy and temp factor are blank - should default to
66    * 1
67    */
 
68  1 toggle @Test(groups = { "Functional" })
69    public void testStringConstructor_blankOccupancyTempFactor()
70    {
71  1 Atom a = new Atom(
72    "ATOM 349 NE2 GLN A 48 22.290 8.595 17.680 N");
73  1 assertEquals(1f, a.occupancy, 0.00001);
74  1 assertEquals(1f, a.tfactor, 0.00001);
75    }
76   
77    /**
78    * Parsing non-numeric data as Atom throws an exception
79    */
 
80  1 toggle @Test(groups = { "Functional" })
81    public void testStringConstructor_malformed()
82    {
83  1 try
84    {
85  1 new Atom(
86    "ATOM 34N NE2 GLN A 48 22.290 8.595 17.680 1.00 14.30 N");
87  0 Assert.fail("Expected exception");
88    } catch (NumberFormatException e)
89    {
90    // expected
91    }
92    }
93    }