PatternObjective.java

1
package com.takenoko.objective;
2
3
import com.takenoko.engine.Board;
4
import com.takenoko.engine.BotState;
5
import com.takenoko.shape.*;
6
import java.util.List;
7
import java.util.Objects;
8
9
public class PatternObjective extends Objective {
10
    private final Pattern pattern;
11
12
    public PatternObjective(Pattern pattern, int points) {
13
        super(ObjectiveType.SHAPE, ObjectiveState.NOT_ACHIEVED, points);
14
        this.pattern = pattern;
15
    }
16
17
    @Override
18
    public void verify(Board board, BotState botState) {
19 1 1. verify : negated conditional → KILLED
        if (!pattern.match(board).isEmpty()) {
20
            state = ObjectiveState.ACHIEVED;
21
        }
22
    }
23
24
    @Override
25
    public void reset() {
26
        state = ObjectiveState.NOT_ACHIEVED;
27
    }
28
29
    @Override
30
    public boolean equals(Object o) {
31 2 1. equals : negated conditional → KILLED
2. equals : replaced boolean return with false for com/takenoko/objective/PatternObjective::equals → KILLED
        if (this == o) return true;
32 3 1. equals : negated conditional → KILLED
2. equals : negated conditional → KILLED
3. equals : replaced boolean return with true for com/takenoko/objective/PatternObjective::equals → KILLED
        if (o == null || getClass() != o.getClass()) return false;
33
        PatternObjective objective = (PatternObjective) o;
34 2 1. equals : replaced boolean return with false for com/takenoko/objective/PatternObjective::equals → KILLED
2. equals : replaced boolean return with true for com/takenoko/objective/PatternObjective::equals → KILLED
        return pattern.equals(objective.pattern);
35
    }
36
37
    @Override
38
    public int hashCode() {
39 1 1. hashCode : replaced int return with 0 for com/takenoko/objective/PatternObjective::hashCode → KILLED
        return Objects.hash(pattern);
40
    }
41
42
    public PatternObjective copy() {
43
        PatternObjective objective = new PatternObjective(pattern, getPoints());
44
        objective.state = state;
45 1 1. copy : replaced return value with null for com/takenoko/objective/PatternObjective::copy → KILLED
        return objective;
46
    }
47
48
    public List<Shape> getShapeToCompletePatternObjective(Board board) {
49 1 1. getShapeToCompletePatternObjective : replaced return value with Collections.emptyList for com/takenoko/objective/PatternObjective::getShapeToCompletePatternObjective → TIMED_OUT
        return pattern.getShapesToCompletePatternObjective(board);
50
    }
51
52
    @Override
53
    public float getCompletion(Board board, BotState botState) {
54
        throw new UnsupportedOperationException();
55
    }
56
57
    @Override
58
    public String toString() {
59 1 1. toString : replaced return value with "" for com/takenoko/objective/PatternObjective::toString → TIMED_OUT
        return "Pattern Objective <" + pattern.toString() + ">";
60
    }
61
62
    /**
63
     * Return the pattern of the objective.
64
     *
65
     * @return the pattern of the objective
66
     */
67
    public Pattern getPattern() {
68 1 1. getPattern : replaced return value with null for com/takenoko/objective/PatternObjective::getPattern → KILLED
        return pattern;
69
    }
70
}

Mutations

19

1.1
Location : verify
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestVerify]/[method:verify_WhenBoardHasTwoTilesNextToEachOther_ThenObjectiveStateIsNOT_ACHIEVED()]
negated conditional → KILLED

31

1.1
Location : equals
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestEquals]/[method:equals_WhenPatternObjectiveIsComparedToNull_ThenItIsNotEqual()]
negated conditional → KILLED

2.2
Location : equals
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestEquals]/[method:equals_WhenPatternObjectiveIsComparedToItself_ThenItIsEqual()]
replaced boolean return with false for com/takenoko/objective/PatternObjective::equals → KILLED

32

1.1
Location : equals
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestEquals]/[method:equals_WhenPatternObjectiveIsComparedToNull_ThenItIsNotEqual()]
negated conditional → KILLED

2.2
Location : equals
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestCopy]/[method:copy_WhenPatternObjectiveIsCopied_ThenItIsEqualToTheOriginal()]
negated conditional → KILLED

3.3
Location : equals
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestEquals]/[method:equals_WhenPatternObjectiveIsComparedToNull_ThenItIsNotEqual()]
replaced boolean return with true for com/takenoko/objective/PatternObjective::equals → KILLED

34

1.1
Location : equals
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestCopy]/[method:copy_WhenPatternObjectiveIsCopied_ThenItIsEqualToTheOriginal()]
replaced boolean return with false for com/takenoko/objective/PatternObjective::equals → KILLED

2.2
Location : equals
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestEquals]/[method:equals_WhenPatternObjectiveIsComparedToAnotherPatternObjectiveWithADifferentPattern_ThenItIsNotEqual()]
replaced boolean return with true for com/takenoko/objective/PatternObjective::equals → KILLED

39

1.1
Location : hashCode
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestHashCode]/[method:hashCode_WhenPatternObjectiveIsComparedToAnotherPatternObjectiveWithADifferentPattern_ThenItHasADifferentHashCode()]
replaced int return with 0 for com/takenoko/objective/PatternObjective::hashCode → KILLED

45

1.1
Location : copy
Killed by : com.takenoko.objective.PatternObjectiveTest.[engine:junit-jupiter]/[class:com.takenoko.objective.PatternObjectiveTest]/[nested-class:TestCopy]/[method:copy_WhenPatternObjectiveIsCopied_ThenItIsEqualToTheOriginal()]
replaced return value with null for com/takenoko/objective/PatternObjective::copy → KILLED

49

1.1
Location : getShapeToCompletePatternObjective
Killed by : none
replaced return value with Collections.emptyList for com/takenoko/objective/PatternObjective::getShapeToCompletePatternObjective → TIMED_OUT

59

1.1
Location : toString
Killed by : none
replaced return value with "" for com/takenoko/objective/PatternObjective::toString → TIMED_OUT

68

1.1
Location : getPattern
Killed by : com.takenoko.bot.unitary.SmartPatternTest.[engine:junit-jupiter]/[class:com.takenoko.bot.unitary.SmartPatternTest]/[nested-class:fillAction]/[method:shouldTryToCompletePatternObjective()]
replaced return value with null for com/takenoko/objective/PatternObjective::getPattern → KILLED

Active mutators

Tests examined


Report generated by PIT 1.8.0