/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testSetParameters() throws ClassNotFoundException, CDKException, Exception { IRule rule = new ChargeRule(); Object[] params = new Object[1]; params[0] = -1.0; rule.setParameters(params); Object[] objects = rule.getParameters(); Assert.assertEquals(1, objects.length); double charge = (Double) objects[0]; Assert.assertEquals(-1.0, charge, 0.00001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testDefaultValidFalse_SetParam() throws ClassNotFoundException, CDKException, Exception { IRule rule = new ChargeRule(); Object[] params = new Object[1]; IMolecularFormula formula = new MolecularFormula(); formula.addIsotope(builder.newIsotope("C"), 2); formula.addIsotope(builder.newIsotope("H"), 200); formula.setCharge(1); params[0] = -1.0; rule.setParameters(params); Assert.assertEquals(0.0, rule.validate(formula), 0.0001); }