@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); } }); }
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; }
@Override public Collection<String> getMutatorNames() { return FCollection.map(this.mutationOperators, toName()); }
private static List<ClassPathRoot> wrapToAvoidIOOperations( List<ClassPathRoot> roots) { return FCollection.map(roots, NameCachingRoot.toCachingRoot()); }
private Function<Category, Iterable<String>> toCategoryNames() { return a -> { if (a == null) { return Collections.emptyList(); } return FCollection.map(Arrays.asList(a.value()),toName()); }; }
public List<Line> convert(final Reader source) throws IOException { try { final InputStreamLineIterable lines = new InputStreamLineIterable(source); return FCollection.map(lines, stringToAnnotatedLine()); } finally { source.close(); } }
private List<TestInfo> prioritizeTests(ClassName clazz, Collection<TestInfo> testsForMutant) { final List<TestInfo> sortedTis = FCollection.map(testsForMutant, Prelude.id(TestInfo.class)); Collections.sort(sortedTis, new TestInfoPriorisationComparator(clazz, TIME_WEIGHTING_FOR_DIRECT_UNIT_TESTS)); return sortedTis; }
private Map<BlockLocation, Set<TestInfo>> blocksToMap( final Collection<BlockCoverage> coverageData) { final Map<BlockLocation, Set<TestInfo>> blockCoverageMap = new HashMap<>(); for (final BlockCoverage blockData : coverageData) { blockCoverageMap.put(blockData.getBlock(), new HashSet<>(FCollection.map(blockData.getTests(), toTestInfo(blockData)))); } return blockCoverageMap; }
private Predicate<String> createClassPredicate() { final Collection<String> classes = new HashSet<>(); for (final File buildOutputDirectory : this.compiledCodeDirectories) { if (buildOutputDirectory.exists()) { final DirectoryClassPathRoot dcRoot = new DirectoryClassPathRoot(buildOutputDirectory); classes.addAll(FCollection.map(dcRoot.classNames(), toPredicate())); } } return Prelude.or(FCollection.map(classes, Glob.toGlobPredicate())); }
@Override public MutationResultListener getListener(final Properties props, final ListenerArguments args) { return new CompoundTestListener(FCollection.map(this.children, factoryToListener(props, args))); }
private ClassPath createClassPathFromElements() { return new ClassPath( FCollection.map(this.classPathElements, stringToFile())); }
public List<MethodTree> methods() { if (this.lazyMethods != null) { return this.lazyMethods; } this.lazyMethods = FCollection.map(this.rawNode.methods, toTree(name())); return this.lazyMethods; }
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); }
private List<String> findModifiedClassNames() throws MojoExecutionException { final File sourceRoot = new File(this.project.getBuild() .getSourceDirectory()); final List<String> modifiedPaths = FCollection.map(findModifiedPaths(), pathByScmDir()); return FCollection.flatMap(modifiedPaths, new PathToJavaClassConverter( sourceRoot.getAbsolutePath())); }
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); }
@Override public Collection<MutationResult> analyse( final Collection<MutationDetails> mutationsForClasses) { return FCollection.map(mutationsForClasses, mutationToResult()); }
private void convertExcludes(ReportOptions option, Xpp3Dom configuration) { List<Predicate<String>> excludes = FCollection.map( extract("excludes", configuration), filenameToClassFilter()); excludes.addAll(option.getExcludedTestClasses()); option.setExcludedTestClasses(excludes); }
private void recordClassPath(final CoverageDatabase coverageData) { final Set<ClassName> allClassNames = getAllClassesAndTests(coverageData); final Collection<HierarchicalClassId> ids = FCollection.map( this.code.getClassInfo(allClassNames), ClassInfo.toFullClassId()); history().recordClassPath(ids, coverageData); }
@Test public void shouldPrioritiseTestsByExecutionTime() { final List<TestInfo> unorderedTests = makeTestInfos(10000, 100, 1000, 1); when(this.coverage.getTestsForClassLine(any(ClassLine.class))).thenReturn( unorderedTests); final List<TestInfo> actual = this.testee.assignTests(makeMutation("foo")); assertEquals(Arrays.asList(1, 100, 1000, 10000), FCollection.map(actual, toTime())); }
@Test public void shouldReturnUniqueTestsForClassWhenSomeTestsCoverClass() { this.testee.calculateClassCoverage(makeCoverageResult("foo", "fooTest", 0, 1)); this.testee.calculateClassCoverage(makeCoverageResult("foo", "fooTest", 0, 2)); this.testee.calculateClassCoverage(makeCoverageResult("foo", "fooTest2", 0, 2)); assertEquals(Arrays.asList("fooTest", "fooTest2"), FCollection.map( this.testee.getTestsForClass(this.foo), testInfoToString())); }