SamplingGatherer.java

1
package com.pivovarit.gatherers;
2
3
import java.util.concurrent.atomic.AtomicLong;
4
import java.util.function.Supplier;
5
import java.util.stream.Gatherer;
6
7
record SamplingGatherer<T>(int n) implements Gatherer<T, AtomicLong, T> {
8
9
    SamplingGatherer {
10
        if (n <= 0) {
11
            throw new IllegalArgumentException("sampling frequency can't be lower than 1");
12
        }
13
    }
14
15
    @Override
16
    public Supplier<AtomicLong> initializer() {
17 1 1. initializer : replaced return value with null for com/pivovarit/gatherers/SamplingGatherer::initializer → KILLED
        return AtomicLong::new;
18
    }
19
20
    @Override
21
    public Integrator<AtomicLong, T, T> integrator() {
22 1 1. integrator : replaced return value with null for com/pivovarit/gatherers/SamplingGatherer::integrator → KILLED
        return Integrator.ofGreedy((state, element, downstream) -> {
23 2 1. lambda$integrator$0 : negated conditional → KILLED
2. lambda$integrator$0 : Replaced long modulus with multiplication → KILLED
            if (state.getAndIncrement() % n == 0) {
24 2 1. lambda$integrator$0 : replaced boolean return with false for com/pivovarit/gatherers/SamplingGatherer::lambda$integrator$0 → SURVIVED
2. lambda$integrator$0 : replaced boolean return with true for com/pivovarit/gatherers/SamplingGatherer::lambda$integrator$0 → SURVIVED
                return downstream.push(element);
25
            }
26 1 1. lambda$integrator$0 : replaced boolean return with false for com/pivovarit/gatherers/SamplingGatherer::lambda$integrator$0 → SURVIVED
            return true;
27
        });
28
    }
29
}

Mutations

17

1.1
Location : initializer
Killed by : com.pivovarit.gatherers.blackbox.SamplingTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.SamplingTest]/[method:shouldSampleEmpty()]
replaced return value with null for com/pivovarit/gatherers/SamplingGatherer::initializer → KILLED

22

1.1
Location : integrator
Killed by : com.pivovarit.gatherers.blackbox.SamplingTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.SamplingTest]/[method:shouldSampleEvery()]
replaced return value with null for com/pivovarit/gatherers/SamplingGatherer::integrator → KILLED

23

1.1
Location : lambda$integrator$0
Killed by : com.pivovarit.gatherers.blackbox.SamplingTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.SamplingTest]/[method:shouldSampleEvery()]
negated conditional → KILLED

2.2
Location : lambda$integrator$0
Killed by : com.pivovarit.gatherers.blackbox.SamplingTest.[engine:junit-jupiter]/[class:com.pivovarit.gatherers.blackbox.SamplingTest]/[method:shouldSampleEvery()]
Replaced long modulus with multiplication → KILLED

24

1.1
Location : lambda$integrator$0
Killed by : none
replaced boolean return with false for com/pivovarit/gatherers/SamplingGatherer::lambda$integrator$0 → SURVIVED
Covering tests

2.2
Location : lambda$integrator$0
Killed by : none
replaced boolean return with true for com/pivovarit/gatherers/SamplingGatherer::lambda$integrator$0 → SURVIVED Covering tests

26

1.1
Location : lambda$integrator$0
Killed by : none
replaced boolean return with false for com/pivovarit/gatherers/SamplingGatherer::lambda$integrator$0 → SURVIVED
Covering tests

Active mutators

Tests examined


Report generated by PIT 1.17.1