RankContext.java

1
package sh.okx.rankup.messages.pebble;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
import org.bukkit.entity.Player;
6
import sh.okx.rankup.RankupPlugin;
7
import sh.okx.rankup.ranks.Rank;
8
import sh.okx.rankup.ranks.RankTree;
9
import sh.okx.rankup.requirements.Requirement;
10
11
public class RankContext {
12
  private final RankupPlugin plugin;
13
  private final Player player;
14
  private final Rank rank;
15
16
  public RankContext(RankupPlugin plugin, Player player, Rank rank) {
17
    this.plugin = plugin;
18
    this.player = player;
19
    this.rank = rank;
20
  }
21
22
  public String getRank() {
23 1 1. getRank : replaced return value with "" for sh/okx/rankup/messages/pebble/RankContext::getRank → KILLED
    return rank.getRank();
24
  }
25
26
  public String getName() {
27 1 1. getName : replaced return value with "" for sh/okx/rankup/messages/pebble/RankContext::getName → KILLED
    return rank.getDisplayName();
28
  }
29
30
  public RequirementContext getRequirement(String requirement) {
31
    Requirement context = rank.getRequirement(player, requirement);
32 1 1. getRequirement : negated conditional → KILLED
    if (context == null) {
33
      throw new InvalidRequirementException(requirement, rank);
34
    }
35 1 1. getRequirement : replaced return value with null for sh/okx/rankup/messages/pebble/RankContext::getRequirement → KILLED
    return new RequirementContext(player, context);
36
  }
37
38
  public RequirementContext getRequirement(String requirement, String sub) {
39 1 1. getRequirement : replaced return value with null for sh/okx/rankup/messages/pebble/RankContext::getRequirement → NO_COVERAGE
    return getRequirement(requirement + "#" + sub);
40
  }
41
42
  public RequirementContext getReq(String requirement) {
43 1 1. getReq : replaced return value with null for sh/okx/rankup/messages/pebble/RankContext::getReq → KILLED
    return getRequirement(requirement);
44
  }
45
46
  public boolean getHas(String requirement) {
47 2 1. getHas : negated conditional → KILLED
2. getHas : replaced boolean return with true for sh/okx/rankup/messages/pebble/RankContext::getHas → KILLED
    return rank.getRequirement(player, requirement) != null;
48
  }
49
50
  public boolean getHas(String requirement, String sub) {
51 2 1. getHas : negated conditional → NO_COVERAGE
2. getHas : replaced boolean return with true for sh/okx/rankup/messages/pebble/RankContext::getHas → NO_COVERAGE
    return rank.getRequirement(player, requirement + "#" + sub) != null;
52
  }
53
54
  public RequirementContext getReq(String requirement, String sub) {
55 1 1. getReq : replaced return value with null for sh/okx/rankup/messages/pebble/RankContext::getReq → NO_COVERAGE
    return getRequirement(requirement, sub);
56
  }
57
58
  public List<RequirementContext> getRequirements() {
59
    List<RequirementContext> list = new ArrayList<>();
60
    for (Requirement requirement : rank.getRequirements().getRequirements(player)) {
61
      list.add(new RequirementContext(player, requirement));
62
    }
63 1 1. getRequirements : replaced return value with Collections.emptyList for sh/okx/rankup/messages/pebble/RankContext::getRequirements → SURVIVED
    return list;
64
  }
65
66
  public boolean getDone() {
67
    for (RequirementContext context : getRequirements()) {
68 1 1. getDone : negated conditional → NO_COVERAGE
      if (!context.getDone()) {
69 1 1. getDone : replaced boolean return with true for sh/okx/rankup/messages/pebble/RankContext::getDone → NO_COVERAGE
        return false;
70
      }
71
    }
72 1 1. getDone : replaced boolean return with false for sh/okx/rankup/messages/pebble/RankContext::getDone → NO_COVERAGE
    return true;
73
  }
74
75
  public int getIndex() {
76
    RankTree<Rank> tree = plugin.getRankups().getTree();
77
    int index = 0;
78
    for (Rank rank : tree) {
79 1 1. getIndex : negated conditional → NO_COVERAGE
      if (rank == this.rank) {
80 1 1. getIndex : replaced int return with 0 for sh/okx/rankup/messages/pebble/RankContext::getIndex → NO_COVERAGE
        return index;
81
      }
82 1 1. getIndex : Changed increment from 1 to -1 → NO_COVERAGE
      index++;
83
    }
84 1 1. getIndex : replaced int return with 0 for sh/okx/rankup/messages/pebble/RankContext::getIndex → NO_COVERAGE
    return -1;
85
  }
86
87
  public String toString() {
88 1 1. toString : replaced return value with "" for sh/okx/rankup/messages/pebble/RankContext::toString → NO_COVERAGE
    return rank.getRank();
89
  }
90
}

Mutations

23

1.1
Location : getRank
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRanks()]
replaced return value with "" for sh/okx/rankup/messages/pebble/RankContext::getRank → KILLED

27

1.1
Location : getName
Killed by : sh.okx.rankup.legacy.LegacyPlaceholderTest.[engine:junit-jupiter]/[class:sh.okx.rankup.legacy.LegacyPlaceholderTest]/[method:testLegacy()]
replaced return value with "" for sh/okx/rankup/messages/pebble/RankContext::getName → KILLED

32

1.1
Location : getRequirement
Killed by : sh.okx.rankup.pebble.PebbleTest.[engine:junit-jupiter]/[class:sh.okx.rankup.pebble.PebbleTest]/[method:testRequirementPresent()]
negated conditional → KILLED

35

1.1
Location : getRequirement
Killed by : sh.okx.rankup.pebble.PebbleTest.[engine:junit-jupiter]/[class:sh.okx.rankup.pebble.PebbleTest]/[method:testRequirementPresent()]
replaced return value with null for sh/okx/rankup/messages/pebble/RankContext::getRequirement → KILLED

39

1.1
Location : getRequirement
Killed by : none
replaced return value with null for sh/okx/rankup/messages/pebble/RankContext::getRequirement → NO_COVERAGE

43

1.1
Location : getReq
Killed by : sh.okx.rankup.pebble.PebbleTest.[engine:junit-jupiter]/[class:sh.okx.rankup.pebble.PebbleTest]/[method:testRequirementPresent()]
replaced return value with null for sh/okx/rankup/messages/pebble/RankContext::getReq → KILLED

47

1.1
Location : getHas
Killed by : sh.okx.rankup.pebble.PebbleTest.[engine:junit-jupiter]/[class:sh.okx.rankup.pebble.PebbleTest]/[method:testRequirementAbsent()]
negated conditional → KILLED

2.2
Location : getHas
Killed by : sh.okx.rankup.pebble.PebbleTest.[engine:junit-jupiter]/[class:sh.okx.rankup.pebble.PebbleTest]/[method:testRequirementAbsent()]
replaced boolean return with true for sh/okx/rankup/messages/pebble/RankContext::getHas → KILLED

51

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

2.2
Location : getHas
Killed by : none
replaced boolean return with true for sh/okx/rankup/messages/pebble/RankContext::getHas → NO_COVERAGE

55

1.1
Location : getReq
Killed by : none
replaced return value with null for sh/okx/rankup/messages/pebble/RankContext::getReq → NO_COVERAGE

63

1.1
Location : getRequirements
Killed by : none
replaced return value with Collections.emptyList for sh/okx/rankup/messages/pebble/RankContext::getRequirements → SURVIVED

68

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

69

1.1
Location : getDone
Killed by : none
replaced boolean return with true for sh/okx/rankup/messages/pebble/RankContext::getDone → NO_COVERAGE

72

1.1
Location : getDone
Killed by : none
replaced boolean return with false for sh/okx/rankup/messages/pebble/RankContext::getDone → NO_COVERAGE

79

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

80

1.1
Location : getIndex
Killed by : none
replaced int return with 0 for sh/okx/rankup/messages/pebble/RankContext::getIndex → NO_COVERAGE

82

1.1
Location : getIndex
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

84

1.1
Location : getIndex
Killed by : none
replaced int return with 0 for sh/okx/rankup/messages/pebble/RankContext::getIndex → NO_COVERAGE

88

1.1
Location : toString
Killed by : none
replaced return value with "" for sh/okx/rankup/messages/pebble/RankContext::toString → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.7.0