ApplyTagsFromCsvCommand.java

1
package org.egothor.methodatlas.command;
2
3
import java.io.IOException;
4
import java.io.PrintWriter;
5
import java.nio.file.Path;
6
import java.nio.file.Paths;
7
import java.util.List;
8
9
import org.egothor.methodatlas.ApplyTagsFromCsvEngine;
10
import org.egothor.methodatlas.CliConfig;
11
import org.egothor.methodatlas.api.SourcePatcher;
12
import org.egothor.methodatlas.api.TestDiscoveryConfig;
13
14
/**
15
 * CLI command handler for the {@code -apply-tags-from-csv} mode.
16
 *
17
 * <p>
18
 * Applies the annotation decisions recorded in a reviewed CSV back to the
19
 * source files. The CSV is treated as a complete desired-state specification:
20
 * every test method's {@code @Tag} set and {@code @DisplayName} are driven
21
 * entirely by the corresponding CSV row.
22
 * </p>
23
 *
24
 * @see ApplyTagsCommand
25
 * @see org.egothor.methodatlas.ApplyTagsFromCsvEngine
26
 */
27
public final class ApplyTagsFromCsvCommand implements Command {
28
29
    private final CliConfig cliConfig;
30
    private final TestDiscoveryConfig discoveryConfig;
31
32
    /**
33
     * Creates a new apply-tags-from-csv command.
34
     *
35
     * @param cliConfig       full parsed CLI configuration
36
     * @param discoveryConfig discovery configuration forwarded to patchers
37
     */
38
    public ApplyTagsFromCsvCommand(CliConfig cliConfig, TestDiscoveryConfig discoveryConfig) {
39
        this.cliConfig = cliConfig;
40
        this.discoveryConfig = discoveryConfig;
41
    }
42
43
    /**
44
     * Applies annotation decisions from the reviewed CSV to source files.
45
     *
46
     * @param out writer for progress and summary output
47
     * @return {@code 0} on success, {@code 1} when the mismatch limit is
48
     *         exceeded or a fatal error occurs
49
     * @throws IOException if the CSV or source files cannot be read or written
50
     */
51
    @Override
52
    public int execute(PrintWriter out) throws IOException {
53 2 1. execute : removed conditional - replaced equality check with false → SURVIVED
2. execute : removed conditional - replaced equality check with true → KILLED
        List<Path> roots = cliConfig.paths().isEmpty() ? List.of(Paths.get(".")) : cliConfig.paths();
54
        List<SourcePatcher> patchers = CommandSupport.loadPatchers(discoveryConfig);
55 1 1. execute : replaced int return with 0 for org/egothor/methodatlas/command/ApplyTagsFromCsvCommand::execute → KILLED
        return ApplyTagsFromCsvEngine.apply(
56
                cliConfig.applyTagsFromCsvFile(),
57
                roots,
58
                cliConfig.mismatchLimit(),
59
                patchers,
60
                out);
61
    }
62
}

Mutations

53

1.1
Location : execute
Killed by : org.egothor.methodatlas.MethodAtlasAppApplyTagsFromCsvTest.[engine:junit-jupiter]/[class:org.egothor.methodatlas.MethodAtlasAppApplyTagsFromCsvTest]/[method:applyTagsFromCsv_addsDisplayNameImportWhenDisplayNameSet(java.nio.file.Path)]
removed conditional - replaced equality check with true → KILLED

2.2
Location : execute
Killed by : none
removed conditional - replaced equality check with false → SURVIVED
Covering tests

55

1.1
Location : execute
Killed by : org.egothor.methodatlas.MethodAtlasAppApplyTagsFromCsvTest.[engine:junit-jupiter]/[class:org.egothor.methodatlas.MethodAtlasAppApplyTagsFromCsvTest]/[method:applyTagsFromCsv_mismatchLimitReturnsOne(java.nio.file.Path)]
replaced int return with 0 for org/egothor/methodatlas/command/ApplyTagsFromCsvCommand::execute → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1