CUTUtil { public static Generation getLatestSuccessfulGeneration(CUT cut) { for (int i = cut.getGeneration().size() - 1; i >= 0; i--) { Generation g = cut.getGeneration().get(i); if (g.isFailed() && g.isModified()) { return null; } else if (!g.isFailed() && g.getSuite() != null) { return g; } } return null; }  static int getNumberStatements(CUT cut); static int getTotalEffort(CUT cut); static int getTimeBudget(CUT cut); static int getTotalEffort(CUT cut, int generationID); static int getTimeBudget(CUT cut, int generationID); static int getNumberTests(CUT cut); static Set<String> getCriteria(CUT cut); static double getCriterionCoverage(CUT cut, String criterionName); static double getOverallCoverage(CUT cut); static Generation getLatestGeneration(CUT cut); static Generation getLatestSuccessfulGeneration(CUT cut);  }
@Test public void testLatestSuccessfulGeneration_Failed_and_Modified() { CUT cut = new CUT(); Generation generation = new Generation(); generation.setFailed(true); generation.setModified(true); cut.getGeneration().add(generation); Assert.assertNull(CUTUtil.getLatestSuccessfulGeneration(cut)); }
@Test public void testLatestSuccessfulGeneration_Failed_not_Modified() { CUT cut = new CUT(); Generation generation = new Generation(); generation.setFailed(true); generation.setModified(false); cut.getGeneration().add(generation); Assert.assertNull(CUTUtil.getLatestSuccessfulGeneration(cut)); }
@Test public void testLatestSuccessfulGeneration_not_Failed_no_Suite() { CUT cut = new CUT(); Generation generation = new Generation(); generation.setFailed(false); generation.setSuite(null); cut.getGeneration().add(generation); Assert.assertNull(CUTUtil.getLatestSuccessfulGeneration(cut)); }
@Test public void testLatestSuccessfulGeneration() { CUT cut = new CUT(); Generation generation = new Generation(); generation.setFailed(false); generation.setSuite(new TestSuite()); cut.getGeneration().add(generation); Assert.assertNotNull(CUTUtil.getLatestSuccessfulGeneration(cut)); }