diff --git a/src/main/org/openscience/cdk/smsd/factory/SubStructureSearchAlgorithms.java b/src/main/org/openscience/cdk/smsd/factory/SubStructureSearchAlgorithms.java index 38d1a6e3cb2..d79cfcb79d1 100644 --- a/src/main/org/openscience/cdk/smsd/factory/SubStructureSearchAlgorithms.java +++ b/src/main/org/openscience/cdk/smsd/factory/SubStructureSearchAlgorithms.java @@ -362,7 +362,7 @@ private void clearMaps() { * */ private void init(MolHandler Reactant, MolHandler Product, boolean removeHydrogen) throws CDKException { - if (Reactant instanceof IQueryAtomContainer) { + if (Product instanceof IQueryAtomContainer) { throw new CDKException( "The first IAtomContainer must not be an IQueryAtomContainer"); } @@ -388,7 +388,7 @@ private void init(MolHandler Reactant, MolHandler Product, boolean removeHydroge @Override @TestMethod("testInit_3args_1") public void init(IMolecule Reactant, IMolecule Product, boolean removeHydrogen) throws CDKException { - if (Reactant instanceof IQueryAtomContainer) { + if (Product instanceof IQueryAtomContainer) { throw new CDKException( "The first IAtomContainer must not be an IQueryAtomContainer"); } @@ -406,7 +406,7 @@ public void init(IMolecule Reactant, IMolecule Product, boolean removeHydrogen) @Override @TestMethod("testInit_3args_2") public void init(IAtomContainer Reactant, IAtomContainer Product, boolean removeHydrogen) throws CDKException { - if (Reactant instanceof IQueryAtomContainer) { + if (Product instanceof IQueryAtomContainer) { throw new CDKException( "The first IAtomContainer must not be an IQueryAtomContainer"); } diff --git a/src/test/org/openscience/cdk/smsd/factory/SubStructureSearchAlgorithmsTest.java b/src/test/org/openscience/cdk/smsd/factory/SubStructureSearchAlgorithmsTest.java index d4ef47edf27..93bca9c247b 100644 --- a/src/test/org/openscience/cdk/smsd/factory/SubStructureSearchAlgorithmsTest.java +++ b/src/test/org/openscience/cdk/smsd/factory/SubStructureSearchAlgorithmsTest.java @@ -25,6 +25,7 @@ import org.junit.Test; import static org.junit.Assert.*; import org.openscience.cdk.DefaultChemObjectBuilder; +import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.exception.InvalidSmilesException; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IMolecule; @@ -58,9 +59,10 @@ public void testSubStructureSearchAlgorithms() { /** * Test of init method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testInit_3args_1() throws InvalidSmilesException { + public void testInit_3args_1() throws InvalidSmilesException, CDKException { System.out.println("init"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IMolecule target = sp.parseSmiles("C\\C=C/OCC=C"); @@ -76,9 +78,10 @@ public void testInit_3args_1() throws InvalidSmilesException { /** * Test of init method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testInit_3args_2() throws InvalidSmilesException { + public void testInit_3args_2() throws InvalidSmilesException, CDKException { System.out.println("init"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/OCC=C"); @@ -115,9 +118,10 @@ public void testInit_3args_3() throws Exception { /** * Test of setChemFilters method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testSetChemFilters() throws InvalidSmilesException { + public void testSetChemFilters() throws InvalidSmilesException, CDKException { System.out.println("setChemFilters"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/OCC=C"); @@ -132,9 +136,10 @@ public void testSetChemFilters() throws InvalidSmilesException { /** * Test of getFragmentSize method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetFragmentSize() throws InvalidSmilesException { + public void testGetFragmentSize() throws InvalidSmilesException, CDKException { System.out.println("getFragmentSize"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -150,9 +155,10 @@ public void testGetFragmentSize() throws InvalidSmilesException { /** * Test of getStereoScore method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetStereoScore() throws InvalidSmilesException { + public void testGetStereoScore() throws InvalidSmilesException, CDKException { System.out.println("getStereoScore"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/OCC=C"); @@ -167,10 +173,11 @@ public void testGetStereoScore() throws InvalidSmilesException { /** * Test of getEnergyScore method, of class SubStructureSearchAlgorithms. - * @throws InvalidSmilesException + * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetEnergyScore() throws InvalidSmilesException { + public void testGetEnergyScore() throws InvalidSmilesException, CDKException { System.out.println("getEnergyScore"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -186,9 +193,10 @@ public void testGetEnergyScore() throws InvalidSmilesException { /** * Test of getFirstMapping method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetFirstMapping() throws InvalidSmilesException { + public void testGetFirstMapping() throws InvalidSmilesException, CDKException { System.out.println("getFirstMapping"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -203,10 +211,11 @@ public void testGetFirstMapping() throws InvalidSmilesException { /** * Test of getAllMapping method, of class SubStructureSearchAlgorithms. - * @throws InvalidSmilesException + * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetAllMapping() throws InvalidSmilesException { + public void testGetAllMapping() throws InvalidSmilesException, CDKException { System.out.println("getAllMapping"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -222,9 +231,10 @@ public void testGetAllMapping() throws InvalidSmilesException { /** * Test of getFirstAtomMapping method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetFirstAtomMapping() throws InvalidSmilesException { + public void testGetFirstAtomMapping() throws InvalidSmilesException, CDKException { System.out.println("getFirstAtomMapping"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -240,9 +250,10 @@ public void testGetFirstAtomMapping() throws InvalidSmilesException { /** * Test of getAllAtomMapping method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetAllAtomMapping() throws InvalidSmilesException { + public void testGetAllAtomMapping() throws InvalidSmilesException, CDKException { System.out.println("getAllAtomMapping"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -258,9 +269,10 @@ public void testGetAllAtomMapping() throws InvalidSmilesException { /** * Test of getReactantMolecule method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetReactantMolecule() throws InvalidSmilesException { + public void testGetReactantMolecule() throws InvalidSmilesException, CDKException { System.out.println("getReactantMolecule"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -276,9 +288,10 @@ public void testGetReactantMolecule() throws InvalidSmilesException { /** * Test of getProductMolecule method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetProductMolecule() throws InvalidSmilesException { + public void testGetProductMolecule() throws InvalidSmilesException, CDKException { System.out.println("getProductMolecule"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -313,9 +326,10 @@ public void testGetTanimotoSimilarity() throws Exception { /** * Test of isStereoMisMatch method, of class SubStructureSearchAlgorithms. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testIsStereoMisMatch() throws InvalidSmilesException { + public void testIsStereoMisMatch() throws InvalidSmilesException, CDKException { System.out.println("isStereoMisMatch"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -332,7 +346,7 @@ public void testIsStereoMisMatch() throws InvalidSmilesException { * @throws InvalidSmilesException */ @Test - public void testIsSubgraph() throws InvalidSmilesException { + public void testIsSubgraph() throws InvalidSmilesException, CDKException { System.out.println("isSubgraph"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); diff --git a/src/test/org/openscience/cdk/smsd/filters/ChemicalFiltersTest.java b/src/test/org/openscience/cdk/smsd/filters/ChemicalFiltersTest.java index b1909955559..f88a58d3094 100644 --- a/src/test/org/openscience/cdk/smsd/filters/ChemicalFiltersTest.java +++ b/src/test/org/openscience/cdk/smsd/filters/ChemicalFiltersTest.java @@ -31,6 +31,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.openscience.cdk.DefaultChemObjectBuilder; +import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.exception.InvalidSmilesException; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.smiles.SmilesParser; @@ -89,10 +90,11 @@ public void testSortResultsByStereoAndBondMatch() throws Exception { /** * Test of sortResultsByFragments method, of class ChemicalFilters. - * @throws InvalidSmilesException + * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testSortResultsByFragments() throws InvalidSmilesException { + public void testSortResultsByFragments() throws InvalidSmilesException, CDKException { System.out.println("sortResultsByFragments"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -176,10 +178,11 @@ public void testSortMapByValueInDecendingOrder() { /** * Test of getSortedEnergy method, of class ChemicalFilters. - * @throws InvalidSmilesException + * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetSortedEnergy() throws InvalidSmilesException { + public void testGetSortedEnergy() throws InvalidSmilesException, CDKException { System.out.println("getSortedEnergy"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -195,9 +198,10 @@ public void testGetSortedEnergy() throws InvalidSmilesException { /** * Test of getSortedFragment method, of class ChemicalFilters. * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetSortedFragment() throws InvalidSmilesException { + public void testGetSortedFragment() throws InvalidSmilesException, CDKException { System.out.println("getSortedFragment"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); @@ -212,10 +216,11 @@ public void testGetSortedFragment() throws InvalidSmilesException { /** * Test of getStereoMatches method, of class ChemicalFilters. - * @throws InvalidSmilesException + * @throws InvalidSmilesException + * @throws CDKException */ @Test - public void testGetStereoMatches() throws InvalidSmilesException { + public void testGetStereoMatches() throws InvalidSmilesException, CDKException { System.out.println("getStereoMatches"); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/OCC=C");