Permalink
Browse files

Molecule From Signature Builder tests

  • Loading branch information...
1 parent 7c46a7c commit 9d2a0c0ff5068ebc6a3491409aa831043206fcdd @gilleain gilleain committed with egonw Jun 15, 2010
View
4 src/main/org/openscience/cdk/signature/MoleculeFromSignatureBuilder.java
@@ -23,6 +23,7 @@
package org.openscience.cdk.signature;
import org.openscience.cdk.annotations.TestClass;
+import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
@@ -60,6 +61,7 @@ public MoleculeFromSignatureBuilder(IChemObjectBuilder builder) {
}
@Override /** {@inheritDoc} */
+ @TestMethod("makeEdgeTest_singleBond,makeEdgeTest_doubleBond,makeEdgeTest_tripleBond")
public void makeEdge(int vertexIndex1, int vertexIndex2,
String vertexSymbol1, String vertexSymbol2, String edgeLabel) {
if (edgeLabel.equals("")) {
@@ -72,11 +74,13 @@ public void makeEdge(int vertexIndex1, int vertexIndex2,
}
@Override /** {@inheritDoc} */
+ @TestMethod("makeGraphTest")
public void makeGraph() {
this.container = this.builder.newInstance(IAtomContainer.class);
}
@Override /** {@inheritDoc} */
+ @TestMethod("makeVertexTest")
public void makeVertex(String label) {
this.container.addAtom(this.builder.newInstance(IAtom.class, label));
}
View
69 src/test/org/openscience/cdk/signature/MoleculeFromSignatureBuilderTest.java
@@ -29,6 +29,7 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
+import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilderTest;
import signature.AbstractVertexSignature;
import signature.ColoredTree;
@@ -123,5 +124,73 @@ public void pentagonRingTest() {
public void hexagonRingTest() {
ringTest(5);
}
+
+ @Test
+ public void makeGraphTest() {
+ MoleculeFromSignatureBuilder builder =
+ new MoleculeFromSignatureBuilder(
+ NoNotificationChemObjectBuilder.getInstance());
+ builder.makeGraph();
+ Assert.assertNotNull(builder.getAtomContainer());
+ }
+
+ @Test
+ public void makeVertexTest() {
+ MoleculeFromSignatureBuilder builder =
+ new MoleculeFromSignatureBuilder(
+ NoNotificationChemObjectBuilder.getInstance());
+ builder.makeGraph();
+ builder.makeVertex("C");
+ IAtomContainer product = builder.getAtomContainer();
+ Assert.assertEquals(1, product.getAtomCount());
+ }
+
+ @Test
+ public void makeEdgeTest_singleBond() {
+ MoleculeFromSignatureBuilder builder =
+ new MoleculeFromSignatureBuilder(
+ NoNotificationChemObjectBuilder.getInstance());
+ builder.makeGraph();
+ builder.makeVertex("C");
+ builder.makeVertex("C");
+ builder.makeEdge(0, 1, "C", "C", "");
+
+ IAtomContainer product = builder.getAtomContainer();
+ Assert.assertEquals(2, product.getAtomCount());
+ Assert.assertEquals(1, product.getBondCount());
+ Assert.assertEquals(IBond.Order.SINGLE, product.getBond(0).getOrder());
+ }
+
+ @Test
+ public void makeEdgeTest_doubleBond() {
+ MoleculeFromSignatureBuilder builder =
+ new MoleculeFromSignatureBuilder(
+ NoNotificationChemObjectBuilder.getInstance());
+ builder.makeGraph();
+ builder.makeVertex("C");
+ builder.makeVertex("C");
+ builder.makeEdge(0, 1, "C", "C", "=");
+
+ IAtomContainer product = builder.getAtomContainer();
+ Assert.assertEquals(2, product.getAtomCount());
+ Assert.assertEquals(1, product.getBondCount());
+ Assert.assertEquals(IBond.Order.DOUBLE, product.getBond(0).getOrder());
+ }
+
+ @Test
+ public void makeEdgeTest_tripleBond() {
+ MoleculeFromSignatureBuilder builder =
+ new MoleculeFromSignatureBuilder(
+ NoNotificationChemObjectBuilder.getInstance());
+ builder.makeGraph();
+ builder.makeVertex("C");
+ builder.makeVertex("C");
+ builder.makeEdge(0, 1, "C", "C", "#");
+
+ IAtomContainer product = builder.getAtomContainer();
+ Assert.assertEquals(2, product.getAtomCount());
+ Assert.assertEquals(1, product.getBondCount());
+ Assert.assertEquals(IBond.Order.TRIPLE, product.getBond(0).getOrder());
+ }
}

0 comments on commit 9d2a0c0

Please sign in to comment.