public static MutationInterceptor nullInterceptor() { return new CompoundMutationInterceptor(Collections.<MutationInterceptor>emptyList()); }
public CompoundMutationInterceptor(List<? extends MutationInterceptor> interceptors) { this.children.addAll(interceptors); Collections.sort(this.children, sortByType()); }
@Test public void shouldNotifyAllChildrenOfEnd() { this.testee = new CompoundMutationInterceptor(Arrays.asList(this.modifyChild,this.filterChild)); this.testee.end(); verify(this.modifyChild).end(); verify(this.filterChild).end(); }
@Override public MutationInterceptor createInterceptor(InterceptorParameters params) { if (params.data().isDetectInlinedCode()) { return new InlinedFinallyBlockFilter(); } return CompoundMutationInterceptor.nullInterceptor(); }
@Test public void shouldNotifyAllChildrenOfNewClass() { this.testee = new CompoundMutationInterceptor(Arrays.asList(this.modifyChild,this.filterChild)); final ClassTree aClass = new ClassTree(null); this.testee.begin(aClass); verify(this.modifyChild).begin(aClass); verify(this.filterChild).begin(aClass); }
@Test public void shouldChainModifiedMutantListsThroughChildrenInCorrectOrder() { // add out of order this.testee = new CompoundMutationInterceptor(Arrays.asList(this.cosmeticChild, this.otherChild, this.modifyChild, this.reportChild, this.filterChild)); final Collection<MutationDetails> original = aMutationDetail().build(1); final Collection<MutationDetails> modifyResult = aMutationDetail().build(2); final Collection<MutationDetails> filterResult = aMutationDetail().build(3); final Collection<MutationDetails> reportResult = aMutationDetail().build(3); final Collection<MutationDetails> cosmeticResult = aMutationDetail().build(3); final Collection<MutationDetails> otherResult = aMutationDetail().build(3); when(this.modifyChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(modifyResult); when(this.filterChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(filterResult); when(this.reportChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(reportResult); when(this.cosmeticChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(cosmeticResult); when(this.otherChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(otherResult); final Collection<MutationDetails> actual = this.testee.intercept(original, this.mutater); assertThat(actual).isEqualTo(reportResult); verify(this.otherChild).intercept(original,this.mutater); verify(this.modifyChild).intercept(otherResult,this.mutater); verify(this.filterChild).intercept(modifyResult,this.mutater); verify(this.cosmeticChild).intercept(cosmeticResult,this.mutater); verify(this.reportChild).intercept(cosmeticResult,this.mutater); }
@Before public void setUp() { when(this.engine.createMutator(any(ClassByteArraySource.class))).thenReturn(this.mutater); this.config = new MutationConfig(this.engine, new LaunchOptions(null)); this.testee = new MutationSource(this.config, this.prioritiser , this.source, CompoundMutationInterceptor.nullInterceptor()); }
IsolationUtils.getContextClassLoader()); final MutationInterceptor emptyIntercpetor = CompoundMutationInterceptor.nullInterceptor();
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); }