org.pitest.mutationtest.build.InterceptorParameters Java Examples

The following examples show how to use org.pitest.mutationtest.build.InterceptorParameters. 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: StopMethodMatcherInterceptorFactory.java    From pitest-descartes with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters interceptorParameters) {
    Set<String> matchers = availabeMatchers.keySet();
    List<String> exclusions = interceptorParameters.getList(EXCEPT);
    if(exclusions != null)
        matchers.removeAll(exclusions);

    return new StopMethodInterceptor(
            StopMethodMatcher.any(
                    matchers.stream()
                            .map(key -> availabeMatchers.get(key))
                            .collect(Collectors.toList())
            )
    );

}
 
Example #2
Source File: LimitNumberOfMutationsPerClassFilterFactory.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  final Optional<Integer> max = params.getInteger(this.limit);
  if (!max.isPresent()) {
    throw new IllegalArgumentException("Max mutation per class filter requires a limit parameter");
  }
  return new LimitNumberOfMutationPerClassFilter(max.get());
}
 
Example #3
Source File: EquivalentReturnMutationFilter.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new CompoundMutationInterceptor(Arrays.asList(new PrimitiveEquivalentFilter(),
      new NullReturnsFilter(),
      new EmptyReturnsFilter(),
      new HardCodedTrueEquivalentFilter())) {
    @Override
    public InterceptorType type() {
      return InterceptorType.FILTER;
    }
  };
}
 
Example #4
Source File: InlinedFinallyBlockFilterFactory.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  if (params.data().isDetectInlinedCode()) {
    return new InlinedFinallyBlockFilter();
  }
  return CompoundMutationInterceptor.nullInterceptor();
}
 
Example #5
Source File: AvoidNullInNotNullInterceptorTest.java    From pitest-descartes with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MutationInterceptor getInterceptor() {
    AvoidNullInNotNullInterceptorFactory factory = new AvoidNullInNotNullInterceptorFactory();
    Feature feature = factory.provides();
    FeatureSetting setting = new FeatureSetting(feature.name(), ToggleStatus.ACTIVATE, Collections.emptyMap());
    InterceptorParameters params = new InterceptorParameters(setting, null, null);
    return new AvoidNullInNotNullInterceptorFactory().createInterceptor(params);
}
 
Example #6
Source File: StopMethodInterceptorTest.java    From pitest-descartes with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MutationInterceptor getInterceptor(String... exclusions) throws IOException {
    StopMethodMatcherInterceptorFactory stopFactory = new StopMethodMatcherInterceptorFactory();
    Feature feature = stopFactory.provides();
    Map<String, List<String>> featureParameters = new HashMap<>();
    featureParameters.put("except", Arrays.asList(exclusions));
    FeatureSetting setting = new FeatureSetting(feature.name(), ToggleStatus.ACTIVATE, featureParameters);
    InterceptorParameters params = new InterceptorParameters(setting, null, null);
    return stopFactory.createInterceptor(params);
}
 
Example #7
Source File: TryWithResourcesFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new TryWithResourcesFilter();
}
 
Example #8
Source File: KotlinInterceptorFactory.java    From pitest-kotlin with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters interceptorParameters) {
  return new KotlinInterceptor();
}
 
Example #9
Source File: ExcludedAnnotationInterceptorFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
private List<String> determineAnnotations(InterceptorParameters params) {
  if (params.getList(ARGUMENT).isEmpty()) {
    return Arrays.asList("Generated", "DoNotMutate", "CoverageIgnore");
  }
  return params.getList(ARGUMENT);
}
 
Example #10
Source File: ExcludedAnnotationInterceptorFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new ExcludedAnnotationInterceptor(determineAnnotations(params));
}
 
Example #11
Source File: KotlinFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new KotlinFilter();
}
 
Example #12
Source File: EqualsPerformanceShortcutFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new EqualsPerformanceShortcutFilter();
}
 
Example #13
Source File: AvoidNullInNotNullInterceptorFactory.java    From pitest-descartes with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters interceptorParameters) {
    return new AvoidNullInNotNullInterceptor();
}
 
Example #14
Source File: AvoidForLoopCountersFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new AvoidForLoopCounterFilter();
}
 
Example #15
Source File: InfiniteForLoopFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new InfiniteForLoopFilter();
}
 
Example #16
Source File: InfiniteIteratorLoopFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new InfiniteIteratorLoopFilter();
}
 
Example #17
Source File: ForEachLoopFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new ForEachLoopFilter();
}
 
Example #18
Source File: EnumConstructorFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
    return new EnumConstructorFilter();
}
 
Example #19
Source File: ImplicitNullCheckFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new ImplicitNullCheckFilter();
}
 
Example #20
Source File: MethodReferenceNullCheckFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new MethodReferenceNullCheckFilter();
}
 
Example #21
Source File: LoggingCallsFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new LoggingCallsFilter(params.data().getLoggingClasses());
}
 
Example #22
Source File: StaticInitializerInterceptorFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new StaticInitializerInterceptor();
}
 
Example #23
Source File: StaticInitializerFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new StaticInitializerFilter();
}
 
Example #24
Source File: MutantExportFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new MutantExportInterceptor(FileSystems.getDefault(), params.source(), params.data().getReportDir());
}