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

The following examples show how to use org.pitest.functional.FCollection#map() . 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: MutatorTestBase.java    From pitest with Apache License 2.0 6 votes vote down vote up
protected void assertMutantsReturn(final Callable<String> mutee,
    final List<MutationDetails> details,
    final String... expectedResults) {

  final List<Mutant> mutants = this.getMutants(details);
  assertEquals("Should return one mutant for each request", details.size(),
      mutants.size());
  final List<String> results = FCollection.map(mutants,
      mutantToStringReults(mutee));

  int i = 0;
  for (final String actual : results) {
    assertEquals(expectedResults[i], actual);
    i++;
  }
}
 
Example 2
Source File: BasePitMojoTest.java    From pitest with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  MockitoAnnotations.initMocks(this);
  this.classPath = new ArrayList<>(FCollection.map(
      ClassPath.getClassPathElementsAsFiles(), fileToString()));
  when(this.project.getTestClasspathElements()).thenReturn(this.classPath);
  when(this.project.getPackaging()).thenReturn("jar");
  
  final Build build = new Build();
  build.setOutputDirectory("");
  
  when(this.project.getBuild()).thenReturn(build);
  
  when(this.plugins.findToolClasspathPlugins()).thenReturn(
      Collections.emptyList());
  when(this.plugins.findClientClasspathPlugins()).thenReturn(
      Collections.emptyList());
}
 
Example 3
Source File: JUnitCustomRunnerTestUnitFinder.java    From pitest with Apache License 2.0 5 votes vote down vote up
private Function<Category, Iterable<String>> toCategoryNames() {
  return a -> {
    if (a == null) {
      return Collections.emptyList();
    }
    return FCollection.map(Arrays.asList(a.value()),toName());
  };
}
 
Example 4
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 5
Source File: ClassInfo.java    From pitest with Apache License 2.0 5 votes vote down vote up
public ClassInfo(final ClassPointer superClass,
    final ClassPointer outerClass, final ClassInfoBuilder builder) {
  this.superClass = superClass;
  this.outerClass = outerClass;
  this.id = builder.id;
  this.access = builder.access;
  this.codeLines = builder.codeLines;
  this.annotations = FCollection.map(builder.annotations,
      ClassName.stringToClassName());
  this.sourceFile = builder.sourceFile;
  this.classAnnotationValues = builder.classAnnotationValues;
}
 
Example 6
Source File: CompoundInterceptorFactory.java    From pitest with Apache License 2.0 5 votes vote down vote up
public MutationInterceptor createInterceptor(
    ReportOptions data,
    ClassByteArraySource source) {
  final List<MutationInterceptor> interceptors = FCollection.map(this.features.getActiveFeatures(),
      toInterceptor(this.features, data, source));
  return new CompoundMutationInterceptor(interceptors);
}
 
Example 7
Source File: AbstractPitAggregationReportMojo.java    From pitest with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
private List<File> convertToRootDirs(final List... directoryLists) {
  final List<String> roots = new ArrayList<>();
  for (final List directoryList : directoryLists) {
    roots.addAll(directoryList);
  }
  return FCollection.map(roots, new Function<String, File>() {
    @Override
    public File apply(final String a) {
      return new File(a);
    }
  });
}
 
Example 8
Source File: CompoundClassPathRoot.java    From pitest with Apache License 2.0 4 votes vote down vote up
private  static List<ClassPathRoot> wrapToAvoidIOOperations(
    List<ClassPathRoot> roots) {
  return FCollection.map(roots, NameCachingRoot.toCachingRoot());
}
 
Example 9
Source File: FeatureParser.java    From pitest with Apache License 2.0 4 votes vote down vote up
public List<FeatureSetting> parseFeatures(Collection<String> config) {
  return FCollection.map(config, stringToSettings());
}
 
Example 10
Source File: NullAnalyser.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MutationResult> analyse(
    final Collection<MutationDetails> mutationsForClasses) {
  return FCollection.map(mutationsForClasses, mutationToResult());
}
 
Example 11
Source File: DefaultTestPrioritiserTest.java    From pitest with Apache License 2.0 4 votes vote down vote up
private List<TestInfo> makeTestInfos(final Integer... times) {
  return new ArrayList<>(FCollection.map(Arrays.asList(times),
      timeToTestInfo()));
}
 
Example 12
Source File: MojoToReportOptionsConverter.java    From pitest with Apache License 2.0 4 votes vote down vote up
private Collection<File> stringsTofiles(final List<String> sourceRoots) {
  return FCollection.map(sourceRoots, stringToFile());
}
 
Example 13
Source File: CoverageData.java    From pitest with Apache License 2.0 4 votes vote down vote up
private static Function<Entry<InstructionLocation, Set<TestInfo>>, BlockCoverage> toBlockCoverage() {
  return a -> new BlockCoverage(a.getKey().getBlockLocation(), FCollection.map(a.getValue(),
      TestInfo.toName()));
}
 
Example 14
Source File: CoverageData.java    From pitest with Apache License 2.0 4 votes vote down vote up
public List<BlockCoverage> createCoverage() {
  return FCollection.map(this.instructionCoverage.entrySet(), toBlockCoverage());
}
 
Example 15
Source File: Mutator.java    From pitest with Apache License 2.0 4 votes vote down vote up
public static Collection<MethodMutatorFactory> byName(final String name) {
  return FCollection.map(MUTATORS.get(name),
      Prelude.id(MethodMutatorFactory.class));
}
 
Example 16
Source File: MutationTestBuilder.java    From pitest with Apache License 2.0 4 votes vote down vote up
private static Function<MutationDetails, Iterable<ClassName>> mutationDetailsToTestClass() {
  return a -> FCollection.map(a.getTestsInOrder(),
      TestInfo.toDefiningClassName());
}
 
Example 17
Source File: GregorMutationEngine.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<String> getMutatorNames() {
  return FCollection.map(this.mutationOperators, toName());
}
 
Example 18
Source File: CompoundListenerFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationResultListener getListener(final Properties props,
    final ListenerArguments args) {
  return new CompoundTestListener(FCollection.map(this.children,
      factoryToListener(props, args)));
}
 
Example 19
Source File: SurefireConfigConverter.java    From pitest with Apache License 2.0 4 votes vote down vote up
private void convertExcludes(ReportOptions option, Xpp3Dom configuration) {
  List<Predicate<String>> excludes = FCollection.map(
      extract("excludes", configuration), filenameToClassFilter());
  excludes.addAll(option.getExcludedTestClasses());
  option.setExcludedTestClasses(excludes);
}
 
Example 20
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()));

  }