BotCSVExporter.java

1
package com.takenoko.stats;
2
3
import java.util.ArrayList;
4
import java.util.HashMap;
5
import java.util.List;
6
import java.util.Map;
7
8
public class BotCSVExporter extends CSVExporter {
9
    private final HashMap<String, SingleBotStatistics> botsData;
10
11
    private final String[] header = new String[] {"Bot Name", "Wins", "Losses", "Final Score"};
12
13
    public BotCSVExporter(String filePath) {
14
        super(filePath);
15
        this.botsData = new HashMap<>();
16
    }
17
18
    @Override
19
    protected void readData(List<String[]> data) {
20
        for (String[] line :
21
                data.stream()
22 2 1. lambda$readData$0 : negated conditional → KILLED
2. lambda$readData$0 : replaced boolean return with true for com/takenoko/stats/BotCSVExporter::lambda$readData$0 → KILLED
                        .filter(line -> !line[0].equals("Bot Name"))
23 1 1. lambda$readData$1 : replaced return value with null for com/takenoko/stats/BotCSVExporter::lambda$readData$1 → KILLED
                        .toArray(String[][]::new)) {
24
            botsData.put(
25
                    line[0],
26
                    new SingleBotStatistics(
27
                            Integer.parseInt(line[1]),
28
                            Integer.parseInt(line[2]),
29
                            Integer.parseInt(line[3])));
30
        }
31
    }
32
33
    @Override
34
    protected List<String[]> writeData() {
35
        List<String[]> contents = new ArrayList<>();
36
        contents.add(header);
37 1 1. writeData : removed call to java/util/HashMap::forEach → KILLED
        botsData.forEach(
38
                (key, value) ->
39
                        contents.add(
40
                                new String[] {
41
                                    key,
42
                                    String.valueOf(value.getWins()),
43
                                    String.valueOf(value.getLosses()),
44
                                    String.valueOf(value.getFinalScore())
45
                                }));
46 1 1. writeData : replaced return value with Collections.emptyList for com/takenoko/stats/BotCSVExporter::writeData → KILLED
        return contents;
47
    }
48
49
    public void addStatistics(BotStatistics botStatistics) {
50 1 1. addStatistics : removed call to com/takenoko/stats/BotStatistics::forEach → KILLED
        botStatistics.forEach(
51
                (key, value) -> {
52 1 1. lambda$addStatistics$3 : negated conditional → KILLED
                    if (botsData.containsKey(key.getName())) {
53 1 1. lambda$addStatistics$3 : removed call to com/takenoko/stats/SingleBotStatistics::addStatistics → NO_COVERAGE
                        botsData.get(key.getName()).addStatistics(value);
54
                    } else {
55
                        botsData.put(key.getName(), value);
56
                    }
57
                });
58
    }
59
60
    public Map<String, SingleBotStatistics> getBotsData() {
61 1 1. getBotsData : replaced return value with Collections.emptyMap for com/takenoko/stats/BotCSVExporter::getBotsData → KILLED
        return botsData;
62
    }
63
}

Mutations

22

1.1
Location : lambda$readData$0
Killed by : com.takenoko.stats.BotCSVExporterTest.[engine:junit-jupiter]/[class:com.takenoko.stats.BotCSVExporterTest]/[nested-class:ReadData]/[method:shouldReadDataFromCSV()]
negated conditional → KILLED

2.2
Location : lambda$readData$0
Killed by : com.takenoko.stats.BotCSVExporterTest.[engine:junit-jupiter]/[class:com.takenoko.stats.BotCSVExporterTest]/[nested-class:ReadData]/[method:shouldReadDataFromCSV()]
replaced boolean return with true for com/takenoko/stats/BotCSVExporter::lambda$readData$0 → KILLED

23

1.1
Location : lambda$readData$1
Killed by : com.takenoko.stats.BotCSVExporterTest.[engine:junit-jupiter]/[class:com.takenoko.stats.BotCSVExporterTest]/[nested-class:ReadData]/[method:shouldReadDataFromCSV()]
replaced return value with null for com/takenoko/stats/BotCSVExporter::lambda$readData$1 → KILLED

37

1.1
Location : writeData
Killed by : com.takenoko.stats.BotCSVExporterTest.[engine:junit-jupiter]/[class:com.takenoko.stats.BotCSVExporterTest]/[nested-class:WriteData]/[method:secondLineShouldBeData()]
removed call to java/util/HashMap::forEach → KILLED

46

1.1
Location : writeData
Killed by : com.takenoko.stats.BotCSVExporterTest.[engine:junit-jupiter]/[class:com.takenoko.stats.BotCSVExporterTest]/[nested-class:WriteData]/[method:firstLineShouldBeHeader()]
replaced return value with Collections.emptyList for com/takenoko/stats/BotCSVExporter::writeData → KILLED

50

1.1
Location : addStatistics
Killed by : com.takenoko.stats.BotCSVExporterTest.[engine:junit-jupiter]/[class:com.takenoko.stats.BotCSVExporterTest]/[nested-class:WriteData]/[method:secondLineShouldBeData()]
removed call to com/takenoko/stats/BotStatistics::forEach → KILLED

52

1.1
Location : lambda$addStatistics$3
Killed by : com.takenoko.stats.BotCSVExporterTest.[engine:junit-jupiter]/[class:com.takenoko.stats.BotCSVExporterTest]/[nested-class:WriteData]/[method:firstLineShouldBeHeader()]
negated conditional → KILLED

53

1.1
Location : lambda$addStatistics$3
Killed by : none
removed call to com/takenoko/stats/SingleBotStatistics::addStatistics → NO_COVERAGE

61

1.1
Location : getBotsData
Killed by : com.takenoko.stats.BotCSVExporterTest.[engine:junit-jupiter]/[class:com.takenoko.stats.BotCSVExporterTest]/[nested-class:ReadData]/[method:shouldReadDataFromCSV()]
replaced return value with Collections.emptyMap for com/takenoko/stats/BotCSVExporter::getBotsData → KILLED

Active mutators

Tests examined


Report generated by PIT 1.8.0