Java Code Examples for org.pitest.functional.FCollection#flatMap()

The following examples show how to use org.pitest.functional.FCollection#flatMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SmartSourceLocator.java    From pitest with Apache License 2.0 5 votes vote down vote up
public SmartSourceLocator(final Collection<File> roots) {
  final Collection<File> childDirs = FCollection.flatMap(roots,
      collectChildren(0));
  childDirs.addAll(roots);

  final Function<File, SourceLocator> fileToSourceLocator = a -> new DirectorySourceLocator(a);
  this.children = FCollection.map(childDirs, fileToSourceLocator);
}
 
Example 2
Source File: MutationTestBuilder.java    From pitest with Apache License 2.0 5 votes vote down vote up
public List<MutationAnalysisUnit> createMutationTestUnits(
    final Collection<ClassName> codeClasses) {
  final List<MutationAnalysisUnit> tus = new ArrayList<>();

  final List<MutationDetails> mutations = FCollection.flatMap(codeClasses,
      classToMutations());

  mutations.sort(comparing(MutationDetails::getId));

  final Collection<MutationResult> analysedMutations = this.analyser
      .analyse(mutations);

  final Collection<MutationDetails> needAnalysis = analysedMutations.stream()
      .filter(statusNotKnown())
      .map(resultToDetails())
      .collect(Collectors.toList());

  final List<MutationResult> analysed = FCollection.filter(analysedMutations,
      Prelude.not(statusNotKnown()));

  if (!analysed.isEmpty()) {
    tus.add(makePreAnalysedUnit(analysed));
  }

  if (!needAnalysis.isEmpty()) {
    for (final Collection<MutationDetails> ms : this.grouper.groupMutations(
        codeClasses, needAnalysis)) {
      tus.add(makeUnanalysedUnit(ms));
    }
  }

  tus.sort(new AnalysisPriorityComparator());
  return tus;
}
 
Example 3
Source File: ReportAggregator.java    From pitest with Apache License 2.0 5 votes vote down vote up
private MutationResultListener createResultListener(final MutationMetaData mutationMetaData) throws ReportAggregationException {
  final SourceLocator sourceLocator = new SmartSourceLocator(this.sourceCodeDirectories);

  final CodeSource codeSource = this.codeSourceAggregator.createCodeSource();
  final CoverageDatabase coverageDatabase = calculateCoverage(codeSource, mutationMetaData);
  final Collection<String> mutatorNames = new HashSet<>(FCollection.flatMap(mutationMetaData.getMutations(), resultToMutatorName()));

  return new MutationHtmlReportListener(coverageDatabase, this.resultOutputStrategy, mutatorNames, sourceLocator);
}
 
Example 4
Source File: JUnitCustomRunnerTestUnitFinder.java    From pitest with Apache License 2.0 4 votes vote down vote up
private List<String> getCategories(final Class<?> a) {
  final Category c = a.getAnnotation(Category.class);
  return FCollection.flatMap(Arrays.asList(c), toCategoryNames());
}
 
Example 5
Source File: ScmMojo.java    From pitest with Apache License 2.0 3 votes vote down vote up
private List<String> findModifiedClassNames() throws MojoExecutionException {

    final File sourceRoot = new File(this.getProject().getBuild()
        .getSourceDirectory());

    final List<String> modifiedPaths = FCollection.map(findModifiedPaths(), pathByScmDir());
    return FCollection.flatMap(modifiedPaths, new PathToJavaClassConverter(
            sourceRoot.getAbsolutePath()));

  }