DrawObjectiveAction.java

1
package com.takenoko.actions.objective;
2
3
import com.takenoko.actions.ActionResult;
4
import com.takenoko.actions.DefaultAction;
5
import com.takenoko.actions.annotations.ActionAnnotation;
6
import com.takenoko.actions.annotations.ActionType;
7
import com.takenoko.engine.Board;
8
import com.takenoko.engine.BotManager;
9
import com.takenoko.engine.BotState;
10
import com.takenoko.objective.ObjectiveType;
11
import java.util.List;
12
import java.util.Objects;
13
14
/** This class is used to draw an objective card. */
15
@ActionAnnotation(ActionType.DEFAULT)
16
public class DrawObjectiveAction implements DefaultAction {
17
    private final ObjectiveType objectiveType;
18
19
    /**
20
     * Constructor. The parameter is mandatory as it allows to choose which type of objective you
21
     * want.
22
     *
23
     * @param objectiveType objectiveType
24
     */
25
    public DrawObjectiveAction(ObjectiveType objectiveType) {
26
        this.objectiveType = objectiveType;
27
    }
28
29
    @Override
30
    public ActionResult execute(Board board, BotManager botManager) {
31 1 1. execute : removed call to com/takenoko/engine/Board::drawObjective → KILLED
        board.drawObjective(objectiveType);
32 1 1. execute : removed call to com/takenoko/engine/BotManager::addObjective → KILLED
        botManager.addObjective(board.peekObjectiveDeck());
33 1 1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
        botManager.displayMessage(
34
                botManager.getName() + " drew objective " + board.peekObjectiveDeck());
35 1 1. execute : removed call to com/takenoko/stats/SingleBotStatistics::updateActions → KILLED
        botManager.getSingleBotStatistics().updateActions(getClass().getSimpleName());
36 1 1. execute : replaced return value with null for com/takenoko/actions/objective/DrawObjectiveAction::execute → KILLED
        return new ActionResult(List.of(DrawObjectiveAction.class), 1);
37
    }
38
39
    public static boolean canBePlayed(Board board, BotState botState) {
40 3 1. canBePlayed : changed conditional boundary → KILLED
2. canBePlayed : negated conditional → KILLED
3. canBePlayed : replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::canBePlayed → KILLED
        return (botState.getObjectives().size()) < BotState.MAX_OBJECTIVES
41 1 1. canBePlayed : negated conditional → KILLED
                && !board.isObjectiveDeckEmpty();
42
    }
43
44
    /**
45
     * Get the objective type of the action
46
     *
47
     * @return ObjectiveType
48
     */
49
    public ObjectiveType getObjectiveType() {
50 1 1. getObjectiveType : replaced return value with null for com/takenoko/actions/objective/DrawObjectiveAction::getObjectiveType → KILLED
        return objectiveType;
51
    }
52
53
    @Override
54
    public boolean equals(Object o) {
55 2 1. equals : negated conditional → NO_COVERAGE
2. equals : replaced boolean return with false for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE
        if (this == o) return true;
56 3 1. equals : negated conditional → NO_COVERAGE
2. equals : negated conditional → NO_COVERAGE
3. equals : replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE
        if (o == null || getClass() != o.getClass()) return false;
57
        DrawObjectiveAction that = (DrawObjectiveAction) o;
58 2 1. equals : negated conditional → NO_COVERAGE
2. equals : replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE
        return objectiveType == that.objectiveType;
59
    }
60
61
    @Override
62
    public int hashCode() {
63 1 1. hashCode : replaced int return with 0 for com/takenoko/actions/objective/DrawObjectiveAction::hashCode → TIMED_OUT
        return Objects.hash(objectiveType);
64
    }
65
}

Mutations

31

1.1
Location : execute
Killed by : com.takenoko.actions.objective.DrawObjectiveActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.objective.DrawObjectiveActionTest]/[nested-class:TestExecute]/[method:execute_shouldReturnActionResultWithDrawObjectiveAction()]
removed call to com/takenoko/engine/Board::drawObjective → KILLED

32

1.1
Location : execute
Killed by : com.takenoko.actions.objective.DrawObjectiveActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.objective.DrawObjectiveActionTest]/[nested-class:TestExecute]/[method:execute_shouldReturnActionResultWithDrawObjectiveAction()]
removed call to com/takenoko/engine/BotManager::addObjective → KILLED

33

1.1
Location : execute
Killed by : none
removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT

35

1.1
Location : execute
Killed by : com.takenoko.actions.objective.DrawObjectiveActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.objective.DrawObjectiveActionTest]/[nested-class:TestExecute]/[method:shouldUpdateActionsInSingleBotStatistics()]
removed call to com/takenoko/stats/SingleBotStatistics::updateActions → KILLED

36

1.1
Location : execute
Killed by : com.takenoko.bot.utils.HistoryAnalysisTest.[engine:junit-jupiter]/[class:com.takenoko.bot.utils.HistoryAnalysisTest]/[nested-class:IntegrationTest]/[method:test1()]
replaced return value with null for com/takenoko/actions/objective/DrawObjectiveAction::execute → KILLED

40

1.1
Location : canBePlayed
Killed by : com.takenoko.actions.objective.DrawObjectiveActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.objective.DrawObjectiveActionTest]/[nested-class:TestCanBePlayed]/[method:canDrawObjective_shouldReturnFalseIfCantDrawObjective()]
changed conditional boundary → KILLED

2.2
Location : canBePlayed
Killed by : com.takenoko.actions.objective.DrawObjectiveActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.objective.DrawObjectiveActionTest]/[nested-class:TestCanBePlayed]/[method:canDrawObjective_shouldReturnTrueIfCanDrawObjective()]
negated conditional → KILLED

3.3
Location : canBePlayed
Killed by : com.takenoko.actions.objective.DrawObjectiveActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.objective.DrawObjectiveActionTest]/[nested-class:TestCanBePlayed]/[method:canDrawObjective_shouldReturnFalseIfObjectiveDeckIsEmpty()]
replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::canBePlayed → KILLED

41

1.1
Location : canBePlayed
Killed by : com.takenoko.actions.objective.DrawObjectiveActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.objective.DrawObjectiveActionTest]/[nested-class:TestCanBePlayed]/[method:canDrawObjective_shouldReturnFalseIfObjectiveDeckIsEmpty()]
negated conditional → KILLED

50

1.1
Location : getObjectiveType
Killed by : com.takenoko.bot.ColletBotTest.[engine:junit-jupiter]/[class:com.takenoko.bot.ColletBotTest]/[nested-class:IntegrationTests]/[method:whenTheBotChoosesAnObjectiveItTakesThePandaOnesIfThereAreSomeAvailables()]
replaced return value with null for com/takenoko/actions/objective/DrawObjectiveAction::getObjectiveType → KILLED

55

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : equals
Killed by : none
replaced boolean return with false for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE

56

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : equals
Killed by : none
replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE

58

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : equals
Killed by : none
replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE

63

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for com/takenoko/actions/objective/DrawObjectiveAction::hashCode → TIMED_OUT

Active mutators

Tests examined


Report generated by PIT 1.8.0