IntChromosomeFactory.java

1
package net.bmahe.genetics4j.core.chromosomes.factory;
2
3
import java.util.Objects;
4
import java.util.random.RandomGenerator;
5
6
import org.apache.commons.lang3.Validate;
7
8
import net.bmahe.genetics4j.core.chromosomes.IntChromosome;
9
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
10
import net.bmahe.genetics4j.core.spec.chromosome.IntChromosomeSpec;
11
12
public class IntChromosomeFactory implements ChromosomeFactory<IntChromosome> {
13
14
	private final RandomGenerator randomGenerator;
15
16
	public IntChromosomeFactory(final RandomGenerator _randomGenerator) {
17
		Objects.requireNonNull(_randomGenerator);
18
19 1 1. <init> : Removed assignment to member variable randomGenerator → KILLED
		this.randomGenerator = _randomGenerator;
20
	}
21
22
	@Override
23
	public boolean canHandle(final ChromosomeSpec chromosomeSpec) {
24
		Objects.requireNonNull(chromosomeSpec);
25
26 2 1. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::canHandle → KILLED
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::canHandle → KILLED
		return chromosomeSpec instanceof IntChromosomeSpec;
27
	}
28
29
	@Override
30
	public IntChromosome generate(final ChromosomeSpec chromosomeSpec) {
31
		Objects.requireNonNull(chromosomeSpec);
32
		Validate.isInstanceOf(IntChromosomeSpec.class, chromosomeSpec);
33
34
		final IntChromosomeSpec intChromosomeSpec = (IntChromosomeSpec) chromosomeSpec;
35
36 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
		int[] values = new int[intChromosomeSpec.size()];
37 6 1. generate : Substituted 0 with 1 → KILLED
2. generate : removed conditional - replaced comparison check with false → KILLED
3. generate : negated conditional → KILLED
4. generate : removed conditional - replaced comparison check with true → KILLED
5. generate : changed conditional boundary → KILLED
6. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
		for (int i = 0; i < intChromosomeSpec.size(); i++) {
38 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
			values[i] = intChromosomeSpec.minValue()
39 6 1. generate : Replaced integer subtraction with addition → SURVIVED
2. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
3. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::maxValue → KILLED
4. generate : Replaced integer addition with subtraction → KILLED
5. generate : replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
6. generate : removed call to java/util/random/RandomGenerator::nextInt → KILLED
					+ randomGenerator.nextInt(intChromosomeSpec.maxValue() - intChromosomeSpec.minValue());
40
		}
41
42 2 1. generate : replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::generate → KILLED
2. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
		return new IntChromosome(intChromosomeSpec.size(),
43 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
				intChromosomeSpec.minValue(),
44 2 1. generate : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::<init> → KILLED
2. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::maxValue → KILLED
				intChromosomeSpec.maxValue(),
45
				values);
46
	}
47
48
}

Mutations

19

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
Removed assignment to member variable randomGenerator → KILLED

26

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:canHandleTest()]
replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::canHandle → KILLED

2.2
Location : canHandle
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:canHandleTest()]
replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::canHandle → KILLED

36

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED

37

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
Substituted 0 with 1 → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
removed conditional - replaced comparison check with false → KILLED

3.3
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
negated conditional → KILLED

4.4
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
removed conditional - replaced comparison check with true → KILLED

5.5
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
changed conditional boundary → KILLED

6.6
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED

38

1.1
Location : generate
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
Covering tests

39

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::maxValue → KILLED

2.2
Location : generate
Killed by : none
Replaced integer subtraction with addition → SURVIVED
Covering tests

3.3
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
Replaced integer addition with subtraction → KILLED

4.4
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED

5.5
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
removed call to java/util/random/RandomGenerator::nextInt → KILLED

6.6
Location : generate
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED Covering tests

42

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::generate → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED

43

1.1
Location : generate
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
Covering tests

44

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::<init> → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:evolveWithIntChromosome()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::maxValue → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.7 support