MultiCombinationsHandler.java

1
package net.bmahe.genetics4j.core.combination.multicombinations;
2
3
import java.util.List;
4
import java.util.Objects;
5
import java.util.random.RandomGenerator;
6
import java.util.stream.Collectors;
7
8
import org.apache.commons.lang3.Validate;
9
10
import net.bmahe.genetics4j.core.combination.ChromosomeCombinator;
11
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorHandler;
12
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorResolver;
13
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
14
import net.bmahe.genetics4j.core.spec.combination.CombinationPolicy;
15
import net.bmahe.genetics4j.core.spec.combination.MultiCombinations;
16
17
public class MultiCombinationsHandler<T extends Comparable<T>> implements ChromosomeCombinatorHandler<T> {
18
19
	private final RandomGenerator randomGenerator;
20
21
	public MultiCombinationsHandler(final RandomGenerator _randomGenerator) {
22
		Objects.requireNonNull(_randomGenerator);
23
24 1 1. <init> : Removed assignment to member variable randomGenerator → SURVIVED
		this.randomGenerator = _randomGenerator;
25
	}
26
27
	@Override
28
	public boolean canHandle(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
29
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) {
30
		Objects.requireNonNull(chromosomeCombinatorResolver);
31
		Objects.requireNonNull(combinationPolicy);
32
		Objects.requireNonNull(chromosome);
33
34
		final boolean isMultiCombinationPolicy = combinationPolicy instanceof MultiCombinations;
35
36 3 1. canHandle : removed conditional - replaced equality check with true → SURVIVED
2. canHandle : negated conditional → KILLED
3. canHandle : removed conditional - replaced equality check with false → KILLED
		if (isMultiCombinationPolicy == false) {
37 2 1. canHandle : Substituted 0 with 1 → KILLED
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → KILLED
			return false;
38
		}
39
40
		final MultiCombinations multiCombinations = (MultiCombinations) combinationPolicy;
41
42 3 1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → NO_COVERAGE
2. canHandle : removed call to net/bmahe/genetics4j/core/spec/combination/MultiCombinations::combinationPolicies → NO_COVERAGE
3. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → NO_COVERAGE
		return multiCombinations.combinationPolicies()
43 1 1. canHandle : removed call to java/util/List::stream → NO_COVERAGE
				.stream()
44 4 1. canHandle : removed call to java/util/stream/Stream::allMatch → NO_COVERAGE
2. lambda$canHandle$0 : removed call to net/bmahe/genetics4j/core/combination/ChromosomeCombinatorResolver::canHandle → NO_COVERAGE
3. lambda$canHandle$0 : replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$canHandle$0 → NO_COVERAGE
4. lambda$canHandle$0 : replaced boolean return with false for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$canHandle$0 → NO_COVERAGE
				.allMatch(cp -> chromosomeCombinatorResolver.canHandle(cp, chromosome));
45
	}
46
47
	@Override
48
	public ChromosomeCombinator<T> resolve(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
49
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) {
50
		Objects.requireNonNull(chromosomeCombinatorResolver);
51
		Objects.requireNonNull(combinationPolicy);
52
		Objects.requireNonNull(chromosome);
53
		Validate.isInstanceOf(MultiCombinations.class, combinationPolicy);
54
55
		final MultiCombinations multiCombinations = (MultiCombinations) combinationPolicy;
56
57 1 1. resolve : removed call to net/bmahe/genetics4j/core/spec/combination/MultiCombinations::combinationPolicies → NO_COVERAGE
		final List<ChromosomeCombinator<T>> chromosomeCombinators = multiCombinations.combinationPolicies()
58 1 1. resolve : removed call to java/util/List::stream → NO_COVERAGE
				.stream()
59 4 1. resolve : removed call to java/util/stream/Stream::map → NO_COVERAGE
2. lambda$resolve$0 : removed call to net/bmahe/genetics4j/core/combination/ChromosomeCombinatorResolver::resolve → NO_COVERAGE
3. lambda$resolve$0 : replaced return value with null for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$resolve$0 → NO_COVERAGE
4. resolve : replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE
				.map(cp -> chromosomeCombinatorResolver.resolve(cp, chromosome))
60 2 1. resolve : removed call to java/util/stream/Stream::collect → NO_COVERAGE
2. resolve : removed call to java/util/stream/Collectors::toList → NO_COVERAGE
				.collect(Collectors.toList());
61
62 2 1. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::resolve → NO_COVERAGE
2. resolve : removed call to net/bmahe/genetics4j/core/combination/multicombinations/MultiChromosomeCombinations::<init> → NO_COVERAGE
		return new MultiChromosomeCombinations<>(randomGenerator, chromosomeCombinators);
63
	}
64
}

Mutations

24

1.1
Location : <init>
Killed by : none
Removed assignment to member variable randomGenerator → SURVIVED
Covering tests

36

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:virtualThreadFactory()]
negated conditional → KILLED

2.2
Location : canHandle
Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:virtualThreadFactory()]
removed conditional - replaced equality check with false → KILLED

3.3
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → SURVIVED
Covering tests

37

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:virtualThreadFactory()]
Substituted 0 with 1 → KILLED

2.2
Location : canHandle
Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:virtualThreadFactory()]
replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → KILLED

42

1.1
Location : canHandle
Killed by : none
replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → NO_COVERAGE

2.2
Location : canHandle
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/combination/MultiCombinations::combinationPolicies → NO_COVERAGE

3.3
Location : canHandle
Killed by : none
replaced boolean return with false for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → NO_COVERAGE

43

1.1
Location : canHandle
Killed by : none
removed call to java/util/List::stream → NO_COVERAGE

44

1.1
Location : canHandle
Killed by : none
removed call to java/util/stream/Stream::allMatch → NO_COVERAGE

2.2
Location : lambda$canHandle$0
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/ChromosomeCombinatorResolver::canHandle → NO_COVERAGE

3.3
Location : lambda$canHandle$0
Killed by : none
replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$canHandle$0 → NO_COVERAGE

4.4
Location : lambda$canHandle$0
Killed by : none
replaced boolean return with false for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$canHandle$0 → NO_COVERAGE

57

1.1
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/combination/MultiCombinations::combinationPolicies → NO_COVERAGE

58

1.1
Location : resolve
Killed by : none
removed call to java/util/List::stream → NO_COVERAGE

59

1.1
Location : resolve
Killed by : none
removed call to java/util/stream/Stream::map → NO_COVERAGE

2.2
Location : lambda$resolve$0
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/ChromosomeCombinatorResolver::resolve → NO_COVERAGE

3.3
Location : lambda$resolve$0
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$resolve$0 → NO_COVERAGE

4.4
Location : resolve
Killed by : none
replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE

60

1.1
Location : resolve
Killed by : none
removed call to java/util/stream/Stream::collect → NO_COVERAGE

2.2
Location : resolve
Killed by : none
removed call to java/util/stream/Collectors::toList → NO_COVERAGE

62

1.1
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::resolve → NO_COVERAGE

2.2
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/multicombinations/MultiChromosomeCombinations::<init> → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.25.7 support