MolecularFormulaGenerator implements IFormulaGenerator { @Override public double getFinishedPercentage() { return formulaGenerator.getFinishedPercentage(); } MolecularFormulaGenerator(final IChemObjectBuilder builder,
                                     final double minMass, final double maxMass,
                                     final MolecularFormulaRange mfRange); @Override IMolecularFormula getNextFormula(); @Override IMolecularFormulaSet getAllFormulas(); @Override double getFinishedPercentage(); @Override void cancel();  }
@Test public void testGetFinishedPercentage() throws Exception { IsotopeFactory ifac = Isotopes.getInstance(); IIsotope c = ifac.getMajorIsotope("C"); IIsotope h = ifac.getMajorIsotope("H"); IIsotope n = ifac.getMajorIsotope("N"); IIsotope o = ifac.getMajorIsotope("O"); MolecularFormulaRange mfRange = new MolecularFormulaRange(); mfRange.addIsotope(c, 0, 10); mfRange.addIsotope(h, 0, 10); mfRange.addIsotope(o, 0, 10); mfRange.addIsotope(n, 0, 10); double minMass = 100.0; double maxMass = 100.05; MolecularFormulaGenerator gen = new MolecularFormulaGenerator(builder, minMass, maxMass, mfRange); double finishedPerc, lastFinishedPerc = 0d; finishedPerc = gen.getFinishedPercentage(); Assert.assertEquals(0d, finishedPerc, 0.0001); while (gen.getNextFormula() != null) { finishedPerc = gen.getFinishedPercentage(); Assert.assertTrue(finishedPerc > lastFinishedPerc); lastFinishedPerc = finishedPerc; } finishedPerc = gen.getFinishedPercentage(); Assert.assertEquals(1d, finishedPerc, 0.0001); }