1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package ffx.potential.bonded;
39
40 import static org.junit.Assert.assertEquals;
41 import static org.junit.Assert.assertNull;
42 import static org.junit.Assert.assertTrue;
43
44 import ffx.potential.parameters.AtomType;
45 import org.jogamp.vecmath.Vector3d;
46 import org.junit.After;
47 import org.junit.Before;
48 import org.junit.Test;
49
50
51 public class AtomTest {
52
53 private final double d[] = {0.0, 0.0, 0.0};
54 private Atom atom = null;
55 private Atom atom2 = null;
56 private Atom atom3 = null;
57 private Bond b = null;
58
59 @Test(timeout = 500)
60 public void Atom_addTrajectoryCoords() {
61 int position = 1;
62 Vector3d v3d = new Vector3d(1.0, 2.0, 3.0);
63 atom.addTrajectoryCoords(v3d, position);
64 atom.setCurrentCycle(2);
65 atom.getV3D(v3d);
66 assertEquals(1.0, v3d.x, 0.0);
67 assertEquals(2.0, v3d.y, 0.0);
68 assertEquals(3.0, v3d.z, 0.0);
69 }
70
71 @Test(timeout = 500)
72 public void Atom_constructor() {
73 String s = "Carbon";
74 Atom actualReturn = new Atom(s);
75 assertEquals("return value", s, actualReturn.getName());
76 }
77
78 @Test(timeout = 500)
79 public void Atom_constructor3() {
80 int index = 0;
81 String i = "N";
82 AtomType mmdata = null;
83 Atom actualReturn = new Atom(index, i, mmdata, d);
84 assertEquals("return value", 0, actualReturn.getIndex());
85 }
86
87 @Test(timeout = 500)
88 public void Atom_constructor4() {
89 int xyznum = 0;
90 String id = "O";
91 Character altLoc = 'A';
92 String r = "GLY";
93 int n = 1;
94 Character c = 'A';
95 Atom actualReturn = new Atom(xyznum, id, altLoc, d, r, n, c, 0.0, 0.0, "A");
96 assertEquals("return value", "GLY", actualReturn.getResidueName());
97 }
98
99 @Test(timeout = 500)
100 public void Atom_destroy() {
101 boolean expectedReturn = true;
102 boolean actualReturn = atom.destroy();
103 assertEquals("return value", expectedReturn, actualReturn);
104 }
105
106 @Test(timeout = 500)
107 public void Atom_equals() {
108 boolean expectedReturn = true;
109 boolean actualReturn = atom.equals(atom);
110 assertEquals("return value", expectedReturn, actualReturn);
111 expectedReturn = false;
112 actualReturn = atom.equals(null);
113 assertEquals("return value", expectedReturn, actualReturn);
114 Atom atom4 = new Atom(atom.getName());
115 expectedReturn = false;
116 actualReturn = atom.equals(atom4);
117 assertEquals("return value", expectedReturn, actualReturn);
118 }
119
120 @Test(timeout = 500)
121 public void Atom_getBond() {
122 Bond expectedReturn = b;
123 Bond actualReturn = atom.getBond(atom2);
124 assertEquals("return value", expectedReturn, actualReturn);
125 actualReturn = atom.getBond(null);
126 assertNull(actualReturn);
127 actualReturn = atom.getBond(atom3);
128 assertNull(actualReturn);
129 }
130
131 @Test(timeout = 500)
132 public void Atom_getNumBonds() {
133 int expectedReturn = 1;
134 int actualReturn = atom.getNumBonds();
135 assertEquals("return value", expectedReturn, actualReturn);
136 }
137
138 @Test(timeout = 500)
139 public void Atom_isBonded() {
140 boolean expectedReturn = true;
141 boolean actualReturn = atom.isBonded(atom2);
142 assertEquals("return value", expectedReturn, actualReturn);
143 expectedReturn = false;
144 actualReturn = atom.isBonded(atom3);
145 assertEquals("return value", expectedReturn, actualReturn);
146 expectedReturn = false;
147 actualReturn = atom.isBonded(null);
148 assertEquals("return value", expectedReturn, actualReturn);
149 }
150
151 @Before
152 public void setUp() {
153 atom = new Atom(1, "C", 'A', d, "GLY", 1, 'A', 0.0, 0.0, "A");
154 atom2 = new Atom("C");
155 atom3 = new Atom("O");
156 b = new Bond(atom, atom2);
157 }
158
159 @After
160 public void tearDown() {
161 assertTrue(atom.destroy());
162 assertTrue(atom2.destroy());
163 assertTrue(atom3.destroy());
164 assertTrue(b.destroy());
165 atom = null;
166 atom2 = null;
167 atom3 = null;
168 b = null;
169 }
170 }