JAL-1805 test envirionment separation
[jalview.git] / test / MCview / AtomTest.java
1 package MCview;
2
3 import static org.testng.AssertJUnit.assertEquals;
4
5 import org.testng.Assert;
6 import org.testng.annotations.Test;
7
8 public class AtomTest
9 {
10
11   /**
12    * Test the constructor that parses a PDB file format ATOM line. Fields are in
13    * fixed column positions
14    */
15   @Test(groups ={ "Functional" })
16   public void testStringConstructor()
17   {
18     Atom a = new Atom(
19             "ATOM    349  NE2 GLN A  48      22.290   8.595  17.680  1.00 14.30           N");
20     assertEquals(349, a.atomIndex);
21     assertEquals("NE", a.name);
22     assertEquals("GLN", a.resName);
23     assertEquals("A", a.chain);
24     assertEquals(48, a.resNumber);
25     assertEquals("48", a.resNumIns);
26     assertEquals(' ', a.insCode);
27     assertEquals(22.290, a.x, 0.00001);
28     assertEquals(8.595, a.y, 0.00001);
29     assertEquals(17.680, a.z, 0.00001);
30     assertEquals(1f, a.occupancy, 0.00001);
31     assertEquals(14.3, a.tfactor, 0.00001);
32   }
33
34   /**
35    * Test the case where occupancy and temp factor are blank - should default to
36    * 1
37    */
38   @Test(groups ={ "Functional" })
39   public void testStringConstructor_blankOccupancyTempFactor()
40   {
41     Atom a = new Atom(
42             "ATOM    349  NE2 GLN A  48      22.290   8.595  17.680                       N");
43     assertEquals(1f, a.occupancy, 0.00001);
44     assertEquals(1f, a.tfactor, 0.00001);
45   }
46
47   /**
48    * Parsing non-numeric data as Atom throws an exception
49    */
50   @Test(groups ={ "Functional" })
51   public void testStringConstructor_malformed()
52   {
53     try
54     {
55       new Atom(
56               "ATOM    34N  NE2 GLN A  48      22.290   8.595  17.680  1.00 14.30           N");
57       Assert.fail("Expected exception");
58     } catch (NumberFormatException e)
59     {
60       // expected
61     }
62   }
63 }