MultiMutationsPolicyHandler.java

1
package net.bmahe.genetics4j.core.mutation;
2
3
import java.util.List;
4
import java.util.random.RandomGenerator;
5
import java.util.stream.Collectors;
6
7
import org.apache.commons.lang3.Validate;
8
9
import net.bmahe.genetics4j.core.Genotype;
10
import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration;
11
import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext;
12
import net.bmahe.genetics4j.core.spec.mutation.MultiMutations;
13
import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy;
14
15
public class MultiMutationsPolicyHandler<T extends Comparable<T>> implements MutationPolicyHandler<T> {
16
17
	private final RandomGenerator randomGenerator;
18
19
	public MultiMutationsPolicyHandler(final RandomGenerator _randomGenerator) {
20
		Validate.notNull(_randomGenerator);
21
22 1 1. <init> : Removed assignment to member variable randomGenerator → SURVIVED
		this.randomGenerator = _randomGenerator;
23
	}
24
25
	@Override
26
	public boolean canHandle(final MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver,
27
			final MutationPolicy mutationPolicy) {
28
		Validate.notNull(mutationPolicyHandlerResolver);
29
		Validate.notNull(mutationPolicy);
30
31 3 1. canHandle : removed conditional - replaced equality check with false → SURVIVED
2. canHandle : removed conditional - replaced equality check with true → KILLED
3. canHandle : negated conditional → KILLED
		if (mutationPolicy instanceof MultiMutations == false) {
32 2 1. canHandle : Substituted 0 with 1 → NO_COVERAGE
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → NO_COVERAGE
			return false;
33
		}
34
35
		final MultiMutations multiMutations = (MultiMutations) mutationPolicy;
36
37 3 1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → SURVIVED
2. canHandle : removed call to net/bmahe/genetics4j/core/spec/mutation/MultiMutations::mutationPolicies → KILLED
3. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → KILLED
		return multiMutations.mutationPolicies()
38 1 1. canHandle : removed call to java/util/List::stream → KILLED
				.stream()
39 4 1. lambda$canHandle$0 : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$canHandle$0 → SURVIVED
2. lambda$canHandle$0 : removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandlerResolver::canHandle → KILLED
3. lambda$canHandle$0 : replaced boolean return with false for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$canHandle$0 → KILLED
4. canHandle : removed call to java/util/stream/Stream::allMatch → KILLED
				.allMatch((mp) -> mutationPolicyHandlerResolver.canHandle(mp));
40
	}
41
42
	@Override
43
	public Mutator createMutator(final AbstractEAExecutionContext<T> eaExecutionContext,
44
			final AbstractEAConfiguration<T> eaConfiguration,
45
			final MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, final MutationPolicy mutationPolicy) {
46
		Validate.notNull(eaExecutionContext);
47
		Validate.notNull(eaConfiguration);
48
		Validate.notNull(mutationPolicyHandlerResolver);
49
		Validate.notNull(mutationPolicy);
50
		Validate.isInstanceOf(MultiMutations.class, mutationPolicy);
51
52
		final MultiMutations multiMutations = (MultiMutations) mutationPolicy;
53
54 1 1. createMutator : removed call to net/bmahe/genetics4j/core/spec/mutation/MultiMutations::mutationPolicies → KILLED
		final List<Mutator> mutators = multiMutations.mutationPolicies()
55 1 1. createMutator : removed call to java/util/List::stream → KILLED
				.stream()
56 2 1. createMutator : replaced call to java/util/stream/Stream::map with receiver → SURVIVED
2. createMutator : removed call to java/util/stream/Stream::map → KILLED
				.map((mp) -> {
57
58 1 1. lambda$createMutator$1 : removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandlerResolver::resolve → KILLED
					final MutationPolicyHandler<T> mutationPolicyHandler = mutationPolicyHandlerResolver.resolve(mp);
59
60 1 1. lambda$createMutator$1 : replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$createMutator$1 → SURVIVED
					return mutationPolicyHandler
61 1 1. lambda$createMutator$1 : removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandler::createMutator → SURVIVED
							.createMutator(eaExecutionContext, eaConfiguration, mutationPolicyHandlerResolver, mp);
62
				})
63 2 1. createMutator : removed call to java/util/stream/Stream::collect → SURVIVED
2. createMutator : removed call to java/util/stream/Collectors::toList → KILLED
				.collect(Collectors.toList());
64
65 4 1. createMutator : removed call to net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler$1::<init> → SURVIVED
2. <init> : Removed assignment to member variable val$mutators → SURVIVED
3. <init> : Removed assignment to member variable this$0 → SURVIVED
4. createMutator : replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::createMutator → SURVIVED
		return new Mutator() {
66
67
			@Override
68
			public Genotype mutate(final Genotype original) {
69
				Validate.notNull(original);
70
71 3 1. mutate : removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
2. mutate : replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE
3. mutate : removed call to java/util/List::size → NO_COVERAGE
				final int selectedMutatorIndex = randomGenerator.nextInt(mutators.size());
72
73 2 1. mutate : removed call to java/util/List::get → NO_COVERAGE
2. mutate : replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler$1::mutate → NO_COVERAGE
				return mutators.get(selectedMutatorIndex)
74 2 1. mutate : removed call to net/bmahe/genetics4j/core/mutation/Mutator::mutate → NO_COVERAGE
2. mutate : replaced call to net/bmahe/genetics4j/core/mutation/Mutator::mutate with argument → NO_COVERAGE
						.mutate(original);
75
			}
76
		};
77
	}
78
}

Mutations

22

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

31

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed conditional - replaced equality check with true → KILLED

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

3.3
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
negated conditional → KILLED

32

1.1
Location : canHandle
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

2.2
Location : canHandle
Killed by : none
replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → NO_COVERAGE

37

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to net/bmahe/genetics4j/core/spec/mutation/MultiMutations::mutationPolicies → KILLED

2.2
Location : canHandle
Killed by : none
replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → SURVIVED
Covering tests

3.3
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
replaced boolean return with false for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → KILLED

38

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to java/util/List::stream → KILLED

39

1.1
Location : lambda$canHandle$0
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandlerResolver::canHandle → KILLED

2.2
Location : lambda$canHandle$0
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
replaced boolean return with false for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$canHandle$0 → KILLED

3.3
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to java/util/stream/Stream::allMatch → KILLED

4.4
Location : lambda$canHandle$0
Killed by : none
replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$canHandle$0 → SURVIVED
Covering tests

54

1.1
Location : createMutator
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to net/bmahe/genetics4j/core/spec/mutation/MultiMutations::mutationPolicies → KILLED

55

1.1
Location : createMutator
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to java/util/List::stream → KILLED

56

1.1
Location : createMutator
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to java/util/stream/Stream::map → KILLED

2.2
Location : createMutator
Killed by : none
replaced call to java/util/stream/Stream::map with receiver → SURVIVED
Covering tests

58

1.1
Location : lambda$createMutator$1
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandlerResolver::resolve → KILLED

60

1.1
Location : lambda$createMutator$1
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$createMutator$1 → SURVIVED
Covering tests

61

1.1
Location : lambda$createMutator$1
Killed by : none
removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandler::createMutator → SURVIVED
Covering tests

63

1.1
Location : createMutator
Killed by : none
removed call to java/util/stream/Stream::collect → SURVIVED
Covering tests

2.2
Location : createMutator
Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
removed call to java/util/stream/Collectors::toList → KILLED

65

1.1
Location : createMutator
Killed by : none
removed call to net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler$1::<init> → SURVIVED
Covering tests

2.2
Location : <init>
Killed by : none
Removed assignment to member variable val$mutators → SURVIVED Covering tests

3.3
Location : <init>
Killed by : none
Removed assignment to member variable this$0 → SURVIVED Covering tests

4.4
Location : createMutator
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::createMutator → SURVIVED Covering tests

71

1.1
Location : mutate
Killed by : none
removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE

2.2
Location : mutate
Killed by : none
replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE

3.3
Location : mutate
Killed by : none
removed call to java/util/List::size → NO_COVERAGE

73

1.1
Location : mutate
Killed by : none
removed call to java/util/List::get → NO_COVERAGE

2.2
Location : mutate
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler$1::mutate → NO_COVERAGE

74

1.1
Location : mutate
Killed by : none
removed call to net/bmahe/genetics4j/core/mutation/Mutator::mutate → NO_COVERAGE

2.2
Location : mutate
Killed by : none
replaced call to net/bmahe/genetics4j/core/mutation/Mutator::mutate with argument → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.6