MassToFormulaTool { public void setDefaultRestrictions() { try { callDefaultRestrictions(); } catch (CDKException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } MassToFormulaTool(IChemObjectBuilder builder); void setRestrictions(List<IRule> rulesNew); List<IRule> getRestrictions(); void setDefaultRestrictions(); IMolecularFormulaSet generate(double mass);  }
@Test public void testSetDefaultRestrictions() { MassToFormulaTool mfTool = new MassToFormulaTool(builder); List<IRule> rules = mfTool.getRestrictions(); Assert.assertNotNull(rules); Assert.assertEquals(3, rules.size()); ElementRule elemR = (ElementRule) rules.get(0); Assert.assertEquals(1, elemR.getParameters().length); Object[] objects = elemR.getParameters(); MolecularFormulaRange mfRange = (MolecularFormulaRange) objects[0]; Assert.assertEquals(4, mfRange.getIsotopeCount()); Assert.assertEquals(15, mfRange.getIsotopeCountMax(ifac.getMajorIsotope("C"))); Assert.assertEquals(0, mfRange.getIsotopeCountMin(ifac.getMajorIsotope("C"))); Assert.assertEquals(15, mfRange.getIsotopeCountMax(ifac.getMajorIsotope("H"))); Assert.assertEquals(0, mfRange.getIsotopeCountMin(ifac.getMajorIsotope("H"))); Assert.assertEquals(15, mfRange.getIsotopeCountMax(ifac.getMajorIsotope("N"))); Assert.assertEquals(0, mfRange.getIsotopeCountMin(ifac.getMajorIsotope("N"))); Assert.assertEquals(15, mfRange.getIsotopeCountMax(ifac.getMajorIsotope("O"))); Assert.assertEquals(0, mfRange.getIsotopeCountMin(ifac.getMajorIsotope("O"))); ChargeRule chargeR = (ChargeRule) rules.get(1); Assert.assertEquals(1, chargeR.getParameters().length); objects = chargeR.getParameters(); double charge = (Double) objects[0]; Assert.assertEquals(0.0, charge, 0.001); ToleranceRangeRule toleranceR = (ToleranceRangeRule) rules.get(2); Assert.assertEquals(2, toleranceR.getParameters().length); objects = toleranceR.getParameters(); double mass = (Double) objects[0]; Assert.assertEquals(0.0, mass, 0.001); double tolerance = (Double) objects[1]; Assert.assertEquals(0.05, tolerance, 0.001); }