@Test public void testIsToTest_NoData() { Project project = new Project(); project.setTotalNumberOfTestableClasses(XSDUtils.convert(0)); Assert.assertTrue(new ProjectStaticData().isToTest("foo.Bar", 3)); }
public boolean isToTest(String className, int n) { if (this.project == null) { return true; } CUT cut = this.project.getCut().parallelStream() .filter(p -> p.getFullNameOfTargetClass().equals(className)) .findFirst().orElse(null); if (cut == null) { return true; } int how_many_generations_so_far = cut.getGeneration().size(); if (cut.getGeneration().get(how_many_generations_so_far - 1).isFailed()) { return true; } if (how_many_generations_so_far < n) { return true; } List<Generation> lastNGenerations = cut.getGeneration().stream() .filter(g -> g.getTimeBudgetInSeconds().intValue() > 0) .skip(how_many_generations_so_far - n) .collect(Collectors.toList()); for (int i = lastNGenerations.size() - 1; i >= 0; i--) { Generation generation = lastNGenerations.get(i); if (generation.isFailed()) { return true; } if (generation.getSuite() != null) { return true; } } return false; }
ProjectStaticData { public boolean isToTest(String className, int n) { if (this.project == null) { return true; } CUT cut = this.project.getCut().parallelStream() .filter(p -> p.getFullNameOfTargetClass().equals(className)) .findFirst().orElse(null); if (cut == null) { return true; } int how_many_generations_so_far = cut.getGeneration().size(); if (cut.getGeneration().get(how_many_generations_so_far - 1).isFailed()) { return true; } if (how_many_generations_so_far < n) { return true; } List<Generation> lastNGenerations = cut.getGeneration().stream() .filter(g -> g.getTimeBudgetInSeconds().intValue() > 0) .skip(how_many_generations_so_far - n) .collect(Collectors.toList()); for (int i = lastNGenerations.size() - 1; i >= 0; i--) { Generation generation = lastNGenerations.get(i); if (generation.isFailed()) { return true; } if (generation.getSuite() != null) { return true; } } return false; } }
ProjectStaticData { public boolean isToTest(String className, int n) { if (this.project == null) { return true; } CUT cut = this.project.getCut().parallelStream() .filter(p -> p.getFullNameOfTargetClass().equals(className)) .findFirst().orElse(null); if (cut == null) { return true; } int how_many_generations_so_far = cut.getGeneration().size(); if (cut.getGeneration().get(how_many_generations_so_far - 1).isFailed()) { return true; } if (how_many_generations_so_far < n) { return true; } List<Generation> lastNGenerations = cut.getGeneration().stream() .filter(g -> g.getTimeBudgetInSeconds().intValue() > 0) .skip(how_many_generations_so_far - n) .collect(Collectors.toList()); for (int i = lastNGenerations.size() - 1; i >= 0; i--) { Generation generation = lastNGenerations.get(i); if (generation.isFailed()) { return true; } if (generation.getSuite() != null) { return true; } } return false; } ProjectStaticData(); }
ProjectStaticData { public boolean isToTest(String className, int n) { if (this.project == null) { return true; } CUT cut = this.project.getCut().parallelStream() .filter(p -> p.getFullNameOfTargetClass().equals(className)) .findFirst().orElse(null); if (cut == null) { return true; } int how_many_generations_so_far = cut.getGeneration().size(); if (cut.getGeneration().get(how_many_generations_so_far - 1).isFailed()) { return true; } if (how_many_generations_so_far < n) { return true; } List<Generation> lastNGenerations = cut.getGeneration().stream() .filter(g -> g.getTimeBudgetInSeconds().intValue() > 0) .skip(how_many_generations_so_far - n) .collect(Collectors.toList()); for (int i = lastNGenerations.size() - 1; i >= 0; i--) { Generation generation = lastNGenerations.get(i); if (generation.isFailed()) { return true; } if (generation.getSuite() != null) { return true; } } return false; } ProjectStaticData(); void initializeLocalHistory(); boolean containsClass(String c); ClassInfo getClassInfo(String name); int getTotalNumberOfClasses(); int getTotalNumberOfTestableCUTs(); int getTotalNumberOfBranches(); Collection<ClassInfo> getClassInfos(); Collection<String> getClassNames(); boolean hasChanged(String javaFileName); boolean isToTest(String className, int n); ProjectGraph getProjectGraph(); }
ProjectStaticData { public boolean isToTest(String className, int n) { if (this.project == null) { return true; } CUT cut = this.project.getCut().parallelStream() .filter(p -> p.getFullNameOfTargetClass().equals(className)) .findFirst().orElse(null); if (cut == null) { return true; } int how_many_generations_so_far = cut.getGeneration().size(); if (cut.getGeneration().get(how_many_generations_so_far - 1).isFailed()) { return true; } if (how_many_generations_so_far < n) { return true; } List<Generation> lastNGenerations = cut.getGeneration().stream() .filter(g -> g.getTimeBudgetInSeconds().intValue() > 0) .skip(how_many_generations_so_far - n) .collect(Collectors.toList()); for (int i = lastNGenerations.size() - 1; i >= 0; i--) { Generation generation = lastNGenerations.get(i); if (generation.isFailed()) { return true; } if (generation.getSuite() != null) { return true; } } return false; } ProjectStaticData(); void initializeLocalHistory(); boolean containsClass(String c); ClassInfo getClassInfo(String name); int getTotalNumberOfClasses(); int getTotalNumberOfTestableCUTs(); int getTotalNumberOfBranches(); Collection<ClassInfo> getClassInfos(); Collection<String> getClassNames(); boolean hasChanged(String javaFileName); boolean isToTest(String className, int n); ProjectGraph getProjectGraph();  }