ShadowDeserializer.java

1
package sh.okx.rankup.serialization;
2
3
import com.electronwill.nightconfig.core.UnmodifiableConfig;
4
import com.electronwill.nightconfig.core.UnmodifiableConfig.Entry;
5
import java.util.ArrayList;
6
import java.util.Collections;
7
import java.util.HashMap;
8
import java.util.List;
9
import java.util.Map;
10
11
public class ShadowDeserializer {
12
13
  public static List<RankSerialized> deserialize(UnmodifiableConfig ranks) {
14
    List<RankSerialized> ranksList = new ArrayList<>(ranks.size());
15
    for (Entry entry : ranks.entrySet()) {
16
      UnmodifiableConfig value = entry.getValue();
17 1 1. deserialize : negated conditional → KILLED
      if (value == null) continue;
18
      String rank = value.get("rank");
19
      String next = value.get("next");
20
      String displayName = value.get("display-name");
21
      List<String> commands = value.getOrElse("commands", Collections.emptyList());
22
      List<String> requirements;
23
      Map<String, List<String>> prestigeRequirements;
24
      Object requirementsObject = value.get("requirements");
25 1 1. deserialize : negated conditional → KILLED
      if (requirementsObject instanceof UnmodifiableConfig) {
26
        requirements = null;
27
        UnmodifiableConfig requirementsConfig = (UnmodifiableConfig) requirementsObject;
28
        prestigeRequirements = new HashMap<>(requirementsConfig.size());
29
        for (Entry requirementEntry : requirementsConfig.entrySet()) {
30
          prestigeRequirements.put(requirementEntry.getKey(), requirementEntry.getValue());
31
        }
32
      } else {
33
        prestigeRequirements = null;
34 1 1. deserialize : negated conditional → KILLED
        if (requirementsObject instanceof String) {
35
          requirements = Collections.singletonList((String) requirementsObject);
36 1 1. deserialize : negated conditional → KILLED
        } else if (requirementsObject instanceof List) {
37
          requirements = (List<String>) requirementsObject;
38
        } else {
39
          requirements = Collections.emptyList();
40
        }
41
      }
42
43
      UnmodifiableConfig messagesConfig = value.get("rankup");
44
      Map<String, String> messages;
45 1 1. deserialize : negated conditional → KILLED
      if (messagesConfig != null) {
46
        messages = new HashMap<>();
47 1 1. deserialize : removed call to sh/okx/rankup/serialization/ShadowDeserializer::updateMap → KILLED
        updateMap(messages, messagesConfig, "rankup.");
48
      } else {
49
        messages = Collections.emptyMap();
50
      }
51
52
      ranksList.add(new RankSerialized(rank, next, displayName, commands, requirements, prestigeRequirements, messages));
53
    }
54 1 1. deserialize : replaced return value with Collections.emptyList for sh/okx/rankup/serialization/ShadowDeserializer::deserialize → KILLED
    return ranksList;
55
  }
56
57
  private static void updateMap(Map<String, String> map, UnmodifiableConfig config, String prefix) {
58
    for (Entry message : config.entrySet()) {
59
      Object value = message.getValue();
60 1 1. updateMap : negated conditional → KILLED
      if (value != null) {
61 1 1. updateMap : negated conditional → KILLED
        if (value instanceof UnmodifiableConfig) {
62 1 1. updateMap : removed call to sh/okx/rankup/serialization/ShadowDeserializer::updateMap → KILLED
          updateMap(map, (UnmodifiableConfig) value, prefix + message.getKey() + ".");
63
        } else {
64
          map.put(prefix + message.getKey(), String.valueOf(value));
65
        }
66
      }
67
    }
68
  }
69
}

Mutations

17

1.1
Location : deserialize
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
negated conditional → KILLED

25

1.1
Location : deserialize
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
negated conditional → KILLED

34

1.1
Location : deserialize
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
negated conditional → KILLED

36

1.1
Location : deserialize
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
negated conditional → KILLED

45

1.1
Location : deserialize
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
negated conditional → KILLED

47

1.1
Location : deserialize
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
removed call to sh/okx/rankup/serialization/ShadowDeserializer::updateMap → KILLED

54

1.1
Location : deserialize
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
replaced return value with Collections.emptyList for sh/okx/rankup/serialization/ShadowDeserializer::deserialize → KILLED

60

1.1
Location : updateMap
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
negated conditional → KILLED

61

1.1
Location : updateMap
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRequirementsNotMet()]
negated conditional → KILLED

62

1.1
Location : updateMap
Killed by : sh.okx.rankup.toml.TomlTest.[engine:junit-jupiter]/[class:sh.okx.rankup.toml.TomlTest]/[method:testRanks()]
removed call to sh/okx/rankup/serialization/ShadowDeserializer::updateMap → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.0