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

The following examples show how to use org.pitest.functional.FCollection#bucket() . 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: FeatureSelector.java    From pitest with Apache License 2.0 6 votes vote down vote up
public List<T> selectFeatures(List<FeatureSetting> features, Collection<T> filters) {
  final List<T> factories = new ArrayList<>(filters);
  final Map<String, Collection<T>> featureMap = FCollection.bucket(factories, byFeatureName());

  final List<T> active = FCollection.filter(factories, isOnByDefault());

  for ( final FeatureSetting each : features ) {
    final Collection<T> providers = featureMap.get(each.feature());
    if ((providers == null) || providers.isEmpty()) {
      throw new IllegalArgumentException("Pitest and its installed plugins do not recognise the feature " + each.feature());
    }

    if (each.addsFeature()) {
      active.addAll(providers);
    }

    if (each.removesFeature()) {
      active.removeAll(providers);
    }
  }

  return active;
}
 
Example 2
Source File: InfiniteLoopFilter.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MutationDetails> intercept(
    Collection<MutationDetails> mutations, Mutater m) {
  final Map<Location,Collection<MutationDetails>> buckets = FCollection.bucket(mutations, mutationToLocation());

  final List<MutationDetails> willTimeout = new ArrayList<>();
  for (final Entry<Location, Collection<MutationDetails>> each : buckets.entrySet() ) {
    willTimeout.addAll(findTimeoutMutants(each.getKey(), each.getValue(), m));
  }
  mutations.removeAll(willTimeout);
  return mutations;
}
 
Example 3
Source File: DefaultGrouper.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public List<List<MutationDetails>> groupMutations(
    final Collection<ClassName> codeClasses,
    final Collection<MutationDetails> mutations) {
  final Map<ClassName, Collection<MutationDetails>> bucketed = FCollection
      .bucket(mutations, byClass());
  final List<List<MutationDetails>> chunked = new ArrayList<>();
  for (final Collection<MutationDetails> each : bucketed.values()) {
    shrinkToMaximumUnitSize(chunked, each);
  }

  return chunked;
}
 
Example 4
Source File: CoverageData.java    From pitest with Apache License 2.0 5 votes vote down vote up
public CoverageData(final CodeSource code, final LineMap lm, Map<InstructionLocation, Set<TestInfo>> instructionCoverage) {
  this.instructionCoverage = instructionCoverage;
  this.code = code;
  this.lm = lm;
  this.classesForFile = FCollection.bucket(this.code.getCode(),
      keyFromClassInfo());
}
 
Example 5
Source File: FeatureSelector.java    From pitest with Apache License 2.0 4 votes vote down vote up
public FeatureSelector(List<FeatureSetting> features, Collection<T> filters) {
  this.settings = FCollection.bucket(features, byFeature());
  this.active = selectFeatures(features, filters);
}